Jump to content

i've got a problem with mysql_num_rows()


manga_

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.