Page 1 of 1

Checking if record already exists in MySQL?

Posted: Mon Jul 26, 2010 5:03 am
by dominod
Hi

I want to check if a record already exist in MySQL database. If it does it shuld echo "It does exist" and if it dont it shuld do nothing..

Now I figured out the following code but it will not work or give me a error message :

Code: Select all

if(mysql_num_rows(mysql_query("SELECT * FROM engines WHERE keyword = '$GKeyword'"))){
echo "Its there";
}
Can anyone help me? :?

Re: Checking if record already exists in MySQL?

Posted: Mon Jul 26, 2010 6:06 am
by requinix

Code: Select all

mysql_query("SELECT * FROM engines WHERE keyword = '$GKeyword'") or die(mysql_error());
What happens if you do that?

Re: Checking if record already exists in MySQL?

Posted: Mon Jul 26, 2010 7:03 am
by dominod
Thanks tasairis but I got the answer from DigitalPoint :)

Have a nice day