manga_ Posted August 23, 2010 Share Posted August 23, 2010 Hi, This is my first post on phpfreaks[dot]com. I want some help on a php code i was writing this night watching a tutorial. Here's the code: if($cat && $name && $desc){ $sql7 = "SELECT * FROM `forum_cats` WHERE `id`='".$cat."'"; $res7 = mysql_query($sql7) or die(mysql_error()); if(mysql_num_rows($res7) == 0){ echo "The forum category you supplied does not exist!\n"; }else{ blablabla... } in cases like this, the mysql_num_rows() function was always working nicely. here for example: $sql3 = "SELECT admin FROM `users` WHERE `id`='".$_SESSION['uid']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); if(mysql_num_rows($res3)==0){ echo "Please login to your account!\n"; }else{ blablabla... } it's working here just fine. i canged my first code into this: if($cat && $name && $desc){ $sql7 = "SELECT * FROM `forum_cats` WHERE `id`='".$cat."'"; $res7 = mysql_query($sql7) or die(mysql_error()); $aaa = mysql_fetch_assoc($res7); if(sizeof($aaa) == 0){ echo "The forum category you supplied does not exist!\n"; }else{ blablabla... } now it works like it is supposed to, but i really want to know what i am doing wrong in the first part. EDIT: I can post a longer code so that maybe there is an error before the script gets to this part. I hope you will understand what i'm talking about Sorry for my English. thanks in advance, Resul. Link to comment https://forums.phpfreaks.com/topic/211561-ive-got-a-problem-with-mysql_num_rows/ Share on other sites More sharing options...
kenrbnsn Posted August 24, 2010 Share Posted August 24, 2010 You didn't tell us why you think the first chunk of code isn't working. Do you get an error? If so, post it. Ken Link to comment https://forums.phpfreaks.com/topic/211561-ive-got-a-problem-with-mysql_num_rows/#findComment-1102960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.