Re: [PHP] failed query results
If no customers are found, then: if (mysql_num_rows($result1)==0) { print theres no such customer!; } - Original Message - From: baldey_uk [EMAIL PROTECTED] To: Php-General [EMAIL PROTECTED] Sent: Sunday, April 28, 2002 7:48 AM Subject: [PHP] failed query results Hello all, i am trying to query a mysql database to see if a customer all ready exists in a database and if so then use there customer id to insert data into another table. Can anyone tell me what valuse mysql returns if the query returns no value? i have the following code: $customer_id_check=(SELECT id FROM $customer_table WHERE firstname = '$firstname' lastname = '$lastname' email = '$email'); $result1=mysql_query($customer_id_check); if (!$result1) { print theres no such customer!; } which i thought should echo 'theres no such customer!' if a customer didnt exist who fitted the query, however it doesnt and if i echo $result1 i get 'Resource id #2 not what i was expecting (was more expecting something along the lines of NULL). Thanks for any help in advance!!! Cheers From baldey_uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] failed query results
On Sunday 28 April 2002 20:48, baldey_uk wrote: $customer_id_check=(SELECT id FROM $customer_table WHERE firstname = '$firstname' lastname = '$lastname' email = '$email'); $result1=mysql_query($customer_id_check); if (!$result1) { print theres no such customer!; } which i thought should echo 'theres no such customer!' if a customer didnt exist who fitted the query, however it doesnt and if i echo $result1 i get 'Resource id #2 not what i was expecting (was more expecting something along the lines of NULL). Have a look at the examples in the php manual and learn how to incorporate error checking in your code. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* BTW, does Jesus know you flame? -- Diane Holt, [EMAIL PROTECTED], to Ed Carp */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] failed query results
On 28 Apr 2002 at 13:48, baldey_uk wrote: $customer_id_check=(SELECT id FROM $customer_table WHERE firstname = '$firstname' lastname = '$lastname' email = '$email'); $result1=mysql_query($customer_id_check); if (!$result1) { print theres no such customer!; } if (isset($result1) !empty($result1) mysql_num_rows($result1) == 0) { print no customer; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php