944,004 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 841
  • PHP RSS
Nov 11th, 2009
0

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

Expand Post »
I keep getting this message

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/j/a/c/jackattacksite/html/register.php on line 80

Here's the code:

php Syntax (Toggle Plain Text)
  1. // Connect to database
  2. include_once "scripts/connect_to_mysql.php";
  3. $emailCHecker = mysql_real_escape_string($email1);
  4. $usernameChecker = mysql_real_escape_string($username);
  5. $emailCHecker = eregi_replace("`", "", $emailCHecker);
  6. $usernameChecker = eregi_replace("`", " ", $usernameChecker);
  7. // Database duplicate e-mail check setup for use below in the error handling if else conditionals
  8. $sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'");
  9. $email_check = mysql_num_rows($sql_email_check);
  10. $sql_username_check = mysql_query("SELECT username FROM myMemebers WHERE username='$usernameChecker'");
  11. $username_check = mysql_num_rows($sql_username_check);

I checked if the variables matched, but they seemed to match. Thanks to anyone who helps
Reputation Points: 10
Solved Threads: 0
Newbie Poster
JackSkylar is offline Offline
1 posts
since Nov 2009
Nov 11th, 2009
-1
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
i believe this generally means that the search of the database is not returning any result... or something along those lines...

you could try adding a catch after the mysql_query's

something like

$sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'") OR die('Error in mysql syntax: ' . mysql_error());

but gl getting this fixed
Reputation Points: 10
Solved Threads: 4
Junior Poster
Merlin33069 is offline Offline
126 posts
since May 2008
Nov 11th, 2009
0
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Click to Expand / Collapse  Quote originally posted by JackSkylar ...
I keep getting this message

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/j/a/c/jackattacksite/html/register.php on line 80

Here's the code:

php Syntax (Toggle Plain Text)
  1. // Connect to database
  2. include_once "scripts/connect_to_mysql.php";
  3. $emailCHecker = mysql_real_escape_string($email1);
  4. $usernameChecker = mysql_real_escape_string($username);
  5. $emailCHecker = eregi_replace("`", "", $emailCHecker);
  6. $usernameChecker = eregi_replace("`", " ", $usernameChecker);
  7. // Database duplicate e-mail check setup for use below in the error handling if else conditionals
  8. $sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'");
  9. $email_check = mysql_num_rows($sql_email_check);
  10. $sql_username_check = mysql_query("SELECT username FROM myMemebers WHERE username='$usernameChecker'");
  11. $username_check = mysql_num_rows($sql_username_check);

I checked if the variables matched, but they seemed to match. Thanks to anyone who helps
are you sure you want to do this way-
PHP Syntax (Toggle Plain Text)
  1. $emailCHecker = eregi_replace("`", "", $emailCHecker);
The proper way to handle the num_rows -
PHP Syntax (Toggle Plain Text)
  1. $email_check = 0;
  2. if(mysql_num_rows($sql_email_check) !='' || mysql_num_rows($sql_email_check) !=FALSE)
  3. {
  4. $email_check = mysql_num_rows($sql_email_check); }
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 11th, 2009
0
Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Don't use ereg (http://php.net/preg), and read the giant READ ME FAQ at the top of the PHP forums then come back here and ask your question again
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: select one checkbox instedof select multiple checkboxes
Next Thread in PHP Forum Timeline: Global Class Variables.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC