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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.