Question:
Error:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource?
Shahbaz
2013-02-22 15:40:39 UTC
im using a script called php melody im having this error since i changed my nameservers to my old server i moved my domain back to my old server which already had this script
this is the error im getting

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/x/public_html/admin/functions.php on line 184
since the file i really large here is the line 185,185


$count = mysql_num_rows($query);
$categories = a_list_cats_simple();

can somebody help me please!
Three answers:
rhino
2013-02-22 16:33:47 UTC
test your connection and make sure you are connecting to your db and table. it may not be connecting and just not giving an error. This would produce an empty result in $query and thus not be a valid resource. Otherwise if you would post your code starting with mysql_query and stop at $count we may be able to see the issue.
mumme
2016-08-07 21:20:04 UTC
You will get this error in case your mysql_query returns false, this might be considering the fact that the tables or fields inside the question do not exist, or the syntax of the question is unsuitable (which it is not), so verify that. You should additionally note the following mistakes in your code: $password = md5(md5("hdihdlfih".$password."Hd6hD5fi3... Including "hdihdlfih" and "Hd6hD5fi3" to the beginning and finish of a password does no longer exchange anything, you have to add a targeted price for every person (probably often called a salt), for instance: $password = md5($password.$userid); where $userid is a unique id for every user pulled from the database, you will have to additionally appreciate that md5() is an extraordinarily susceptible algorithm and doing it twice wont trade some thing, you should look into utilizing some thing like crypt(). $query = mysql_query("decide upon * FROM users the place username='$person'"); variables are case-sensitive and hanging $user alternatively of $consumer wont work. Other stuff that you just could care about: if ($person) and if ($password) even tho it shouldnt be a challenge, if a username or a password of a user equivalates to false (equivalent to "zero") then this may fail, you might use if(isset($user)); as an alternative. Require("connect.Hypertext Preprocessor"); if for some motive requiring the file fails then your script will throw a fatal error and stop executing , you are significantly better making use of include_once("./join.Personal home page"); after which checking the connection if($connection) and using your own error message if the connection failed.
Chris
2013-02-22 16:46:21 UTC
Just so we're clear: $query is the result of a mysql_query() call, right? As opposed to the query itself?

Because I'm wondering why PHP didn't throw an error sooner if this is caused by a db connection issue.



To be on the safe side, do this:

if ($query === false) {

echo "Query fail";

exit;

}

$count = mysql_num_rows($query);


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...