Catching a mysql_error
| From: | shaun | Date: | Sun, 27 Apr 2003 18:58:04 +0000 |
| Subject: | Catching a mysql_error | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27388@lists.php.net to get a copy of this message | ||
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