Re: Catching a mysql_error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux