Hello
I have table in postgressql with primare key (pk_user). If i insert wrong parametrs.
postgres call exception:( ERROR: duplicate key value violates unique constraint "pk_user" )
this is ok, but i like catch this error and transform it to user interface ( this username is used)
my php script:
$sql="INSERT INTO user (....) VALUES (....)"
@$result=pg_query($dbconn,$sql);
if(!$result) {
$error= pg_last_error($dbconn);
if($error==='ERROR: duplicate key value violates unique constraint "pk_user"')
$outputmesage="this username is used";
....
}
else {
.....
}
but construction if($error==='ERROR: duplicate key value violates unique constraint "pk_user"')
is wrong. I don know what write this. Function strcmp(str1,str2) is wrong too.
P.s: I'm sorry for my bad english