mysql - PHP: How to check if ID in database exists -


Why will not this send the user to user.php if the ID is not present in the table?

  & lt ;? Php included 'db_connect.php'; $ Id_exists = false; $ Url_id = mysql_real_escape_string ($ _GET ['id']); $ Sql ​​= "Selection ID from members where id = '$ url_id'"; $ Result = mysql_query ($ sql); If ($ result == $ url_id) {$ id_exists = true; } And if ($ result! = $ Url_id) {$ id_exists = false; Header ("location: user.php"); Go out(); }? & Gt;   

Thx in advance!

  $ url_id = mysql_real_escape_string ($ _elected ['id']); $ Sql ​​= "Selection ID from members where id = '$ url_id'"; $ Result = mysql_query ($ sql); If (mysql_num_rows ($ result) & gt; 0) {// found} else {// not found}   

try something like that :).

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

ruby on rails - Convert a Activerecord result with has_one associations into a single hash per record -

javascript - Read complete data from stream from onMessage -