Re: Catching a mysql_error
| From: | Rasmus Lerdorf | Date: | Sun, 27 Apr 2003 19:05:11 +0000 |
| Subject: | Re: Catching a mysql_error | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-27389@lists.php.net to get a copy of this message | ||
php.net/mysql_errno
php.net/mysql_error
On Sun, 27 Apr 2003, shaun wrote:
> 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
>
>
>
>