FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Strange "mysql_num_rows()" error (Solved)





EtherealDesert
Hey people. I've installed WpQuiz on my site (niiiiiiice app), and get this weird and strange error:


"Warning: Wrong parameter count for mysql_num_rows() in /questions.php on line 248"

Does this sound familiar anyone? The REALLY strange thing is... that everything works perfectly - as far as I can see.

Maybe I can alter some code - to make the error message go away... if not the error itself?
Bondings
EtherealDesert wrote:
Hey people. I've installed WpQuiz on my site (niiiiiiice app), and get this weird and strange error:


"Warning: Wrong parameter count for mysql_num_rows() in /questions.php on line 248"

Does this sound familiar anyone? The REALLY strange thing is... that everything works perfectly - as far as I can see.

Maybe I can alter some code - to make the error message go away... if not the error itself?

It is a warning, so there must be some code not working properly. I would first try to fix it.

To get rid of that warning, you can turn error reporting off in php.
EtherealDesert
Yeah, well. Everything seems to be wrong now actually. Now it's not even marking answers as correct, even though they are. And it gets weirder. Because I've reinstalled the whole thing. Reinstalled the SQL db, user and added the user to the db. I've configured the script in one smooth flow, it made no fuzz, no nothing and said everything was dandy. I've even installed one single question... just to make it as simple as possible. But still. I'm gonna cry... wwwaaaaaaa....
Bondings
If you really see no way out, I can always recreate your account. That might solve your problems. But I suggest to first take a look at the error messages, maybe even post the url to it, so we can have a look?
EtherealDesert
Sure Smile

The main is:

http://www.debate.frihost.net

And the single question is at:

http://www.debate.frihost.net/questions.php?id=1
Bondings
Ok, I found the page and registered. Can you please paste the code arround line 248 in here?
EtherealDesert
Ok. Don't shot me or anything. I've got the code. But don't really have a cue on how to isolate those lines. Should I coun't the whole thing? Shivers.
Bondings
EtherealDesert wrote:
Ok. Don't shot me or anything. I've got the code. But don't really have a cue on how to isolate those lines. Should I coun't the whole thing? Shivers.

No, there is actually a catch, php counts a new line every 25 characters, so you'll also have to count those. (just kidding)

I suggest you to install EditPlus to edit and view php (and other) code. It has line numbers! http://www.editplus.com/ (free trial version)

But I'm going to have a look at your code myself, but I can't promise anything.
Bondings
Code:
switch ( $qset['questionorder'] ){
   case "1":
      break;
   case "2":
      $ordering = "ORDER BY id DESC";
      break;
   case "3":
      $ordering = "ORDER BY question";
      break;
   case "4":
      $ordering = "ORDER BY question DESC";
      break;
   case "5":
      mysql_query("SELECT * FROM questions WHERE setid='".$no."'");
      $order_limit = mysql_num_rows();
      $ordering = "ORDER BY RAND() LIMIT ".$order_limit;
      break;
   default:
      break;
}

Is the code which gives the error. (the mysql_query and then mysql_num_rows())
Bondings
Maybe try to change this to:
Code:
switch ( $qset['questionorder'] ){
   case "1":
      break;
   case "2":
      $ordering = "ORDER BY id DESC";
      break;
   case "3":
      $ordering = "ORDER BY question";
      break;
   case "4":
      $ordering = "ORDER BY question DESC";
      break;
   case "5":
      $result_questions=mysql_query("SELECT * FROM questions WHERE setid='".$no."'");
      $order_limit = mysql_num_rows($result_questions);
      $ordering = "ORDER BY RAND() LIMIT ".$order_limit;
      break;
   default:
      break;
}

I changed the following code. (added the green color)
$result_questions=mysql_query("SELECT * FROM questions WHERE setid='".$no."'");
$order_limit = mysql_num_rows($result_questions);

There might be a chance that this solves your problem, but I doubt it.
Daniel15
Yeah, Bondings is right. mysql_fetch_rows() expects 1 argument, which is the result id of the query. The code Bondings posted should fix this.... I guess the developers had error reporting turned off?

I just can't stand errors in PHP programs... When I write a script, I try to make sure there's no errors, even the smallest Notice-type error.
EtherealDesert
Wooooot! Thanks man. That code really was flawed, and the changes worked wonders. I'm quite surprised at this actually. This script is so smooth and cool, and then this rather eery fault. Anyhow. Everythings just fiiiiine now Wink
Bondings
Wow, I couldn't believe this either, so I had to check it out. And yes, dracula gave me 1/1=100% instead of a warning. Very Happy
Related topics
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.