Re: Catching a mysql_error
| From: | Ignatius Reilly | Date: | Sun, 27 Apr 2003 19:08:21 +0000 |
| Subject: | Re: Catching a mysql_error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27390@lists.php.net to get a copy of this message | ||
You are checking the wrong thing. Try:
$query = "INSERT INTO MyTable (Col1) VALUES ('x');
if( !$result = mysql_query($query) ) {
echo "Please choose a unique name";
}
HTH
Ignatius
____________________________________________
----- Original Message -----
From: "shaun" <shaun@mania.plus.com>
To: <php-db@lists.php.net>
Sent: Sunday, April 27, 2003 8:58 PM
Subject: [PHP-DB] Catching a mysql_error
> Hi,
>
> Say i have a table with a primary key column, and i try to insert a
matching
> row with a PHP script. Is it possible to catch the errror number and
report
> this back to the user?
>
> $query = "INSERT INTO MyTable (Col1) VALUES ('x');
> $result = @mysql_query($query);
> if(mysql_error = //what do i put here){
> echo "Please choose a unique name";
> }
>
> Thanks for your help
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>