Jump to content

How to check if a record/row exists in a table


mpsn

Recommended Posts

Hi, I just want to know how to check if a row/record already exists for a given table, but this code gives me message in browser: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in myTest.php

 

This is the the snippet I am running:

<?php
$connxn=mysql_connect("localhost","root");
$db=mysql_select_db("siliconvalley");
$toyNodePath="#document/siliconValleyHELLO";
$queryA=mysql_query("SElECT FROM pathexpress (path_express) WHERE path_express='$toyNodePath'");//make sure AT MOST ONE ROW EXISTS!!
if(mysql_num_rows($queryA)==1)
print "ALREADY IN table pathexpress!";
else {
mysql_query("INSERT INTO pathexpress (path_express) VALUES ('$toyNodePath')");
print "ADDED $toyNodePath to table pathexpress!";
}

?>

Please, any help is greatly appreciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.