MeGa
01-03-2004, 07:05 PM
what would be the code to check if an ID does NOT exists? i can do a long code, but i was wonderting is there is some kind of those funcstions that no one knows about from mysql
thanks a lot
thanks a lot
|
||||
php mysqlMeGa 01-03-2004, 07:05 PM what would be the code to check if an ID does NOT exists? i can do a long code, but i was wonderting is there is some kind of those funcstions that no one knows about from mysql thanks a lot Nightfire 01-03-2004, 07:43 PM Do a query to see if it exists or not. $query = mysql_query("SELECT id WHERE id='$idnumber'"); if(mysql_num_rows($query) > 0)){ echo 'ID exists'; }else{ echo 'ID doesnt exist'; } Or I guess I could've done $query = mysql_query("SELECT id WHERE id='$idnumber'"); if($query){ echo 'ID exists'; }else{ echo 'ID doesnt exist'; } ReadMe.txt 01-03-2004, 09:18 PM actually your second one wont work, as mysql_query returns true if the query is executed successfully, whether is returns any rows or not. Nightfire 01-03-2004, 09:21 PM lol I dunno why I came back 2 hours later and added the second bit in. Think the coffee is getting to me. |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum