Re: testing a query for success--code doesnt work
| From: | Kevin Stone | Date: | Tue, 04 Feb 2003 20:59:20 +0000 |
| Subject: | Re: testing a query for success--code doesnt work | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-134332@lists.php.net to get a copy of this message | ||
FYI, I replied to a similar problem just a few threads down. Next time
please consider searching before you post. You'll find you can answer your
own question 9 out of 10 times.
$result = mysql_query("UPDATE or INSERT or DELETE... ") or die("Invalid
query: " . mysql_error());
if (mysql_affected_rows() == 0)
{
echo "Query executed but no rows were affected";
exit;
}
- Kevin
----- Original Message -----
From: "Sunfire" <rusty_81@msn.com>
To: <php-general@lists.php.net>
Sent: Tuesday, February 04, 2003 1:51 PM
Subject: [PHP] testing a query for success--code doesnt work
> hi..
> posted a message about what the code was to test an update query to see if
> it was successfull using mysql and i tested my code and for some reason
even
> if none of the fields were updated it still reports the success message...
>
> heres the code i have:
> $query=mysql_query("update members set company="\$company\", ........);
> if($query){
> message if successfull...
> }
> else{
> message if not or if failed..//never gets used
> }
> anybody know why this doesnt work if 0 records were changed?
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>