Forum Moderators: coopster

Message Too Old, No Replies

Custom Duplicate Entry

Echoing back to page if Unique Field is a duplicate.

         

inveni0

6:32 am on Feb 15, 2006 (gmt 0)

10+ Year Member



I have a form users can fill out in which they create a unique field. How can I simply echo back to the page if the text they enter already exists in the database without the ugly old default error?

dreamcatcher

8:21 am on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don`t use mysql_error(), instead test the state of the query.

$query = mysql_query("...

if ($query)
{
//ok
}
else
{
//not ok
}

dc

inveni0

1:02 pm on Feb 15, 2006 (gmt 0)

10+ Year Member



I'm not sure I understand.

jatar_k

5:10 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try and select the row using the data they enter, if it returns something then it is duplicate data, if it does not then you can carry on with your insert.

dreamcatcher

8:21 am on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you said 'ugly old default error' I figured you meant the error that using mysql_error() throws? So, instead of using that test the query. Or do as jatar_k mentioned.

dc