I am trying to run the code and it seems to be given me wrong result, I tried many ways and still not getting it. Here it is:
//compares vid num to db been result
$id = mysql_real_escape_string(@$_GET['g']);
$vid = mysql_real_escape_string(@$_GET['v']);
$sql= mysql_query("SELECT videos.* FROM videos WHERE videos.email =
(SELECT email FROM page WHERE page.user_id = '$id')
AND videos.videoid = '$vid'");
if (mysql_num_rows($sql) == 0) { echo "none";} else echo "it exists";
If I run the query in phpmyadmin it runs correct, but when run in PHP the result is offfff, it keeps echoing it exists even when phpmyadmin returns 0 which is correct. I have been trying to figure this out and keeps getting nothing. I have tried !isset($sql) oppositely the something.
解决方案if ( $sql ) // valid result
{
if ( mysql_num_rows( $sql ) > 0 ) // more than 0 records
echo "it exists";
else
echo "none";
}
If the above code still gives you a problem, then something in your mysql query is causing a result to be found.