...

View Full Version : query



bunny1
03-19-2007, 11:49 PM
I want to check if an item is already in the database and have an if statement.
I am trying


if(@mysql_fetch_array($result1)!= null)
{
...
}

I know this is wrong.But not sure what it should be

Thanks

Fumigator
03-19-2007, 11:55 PM
$query = "SELECT count(*) FROM table1 WHERE field1 = 'whatever it is that identifies the item uniquely'";
$result = mysql_query($query);
if (!$result) {
die("SQL error: ".mysql_error());
}
if (mysql_result($result, 0) == 1) {
echo "Row already in table";
} else {
echo "Row not in table";
}

bunny1
03-20-2007, 12:17 AM
thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum