Jump to content

mysql_num_rows


karimali831

Recommended Posts

Hi,

 

Got a problem.

 

For the first one, it will die if no rows.

$registered=safe_query("'");
if(!mysql_num_rows($registered)) die();
while($dd=mysql_fetch_array($registered)) {
...
}

 

For this one, it does not die if there is no rows and I'm not sure why?

When it is under fetch it does not understand or something?

 

$registered=safe_query("'");
while($dd=mysql_fetch_array($registered)) {
if(!mysql_num_rows($registered)) die();
...
}

 

I need it under for reasons.

what can I do or is there something else I can use so that it will work in the loop?

 

Thank you for help.

Link to comment
Share on other sites

There maybe rows and there maybe no rows, rows is checked when the user is logged in.

 

$registered=safe_query("SELECT * FROM ".PREFIX."cup_clans WHERE clanID='".$te['clanID']."' && 1on1='0' && cupID='$cupID'");

 

But as you say loop won't run if these is no rows then I can't use mysql_num_rows under it?

Link to comment
Share on other sites

If the loop doesn't run, then neither does any code inside the loop.  Although, in theory you could do.

 

$registered=safe_query("'");
$num = mysql_num_rows($registered);
while($dd=mysql_fetch_array($registered)) {
if($num == 0) die();
...
}

Although, I don't know why you would want to.

Link to comment
Share on other sites

Unrelated but always put variables like:

$te['clanID']

as:

{$te['clanID']} inside strings.

 

The reason the second doesn't die is because the while is never met.

 

if you type in:

while(false) {echo "do something";} 

the code will never execute.

 

You can't fetch from 0 rows.

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.