doddsey_65 Posted December 17, 2010 Share Posted December 17, 2010 i have a simple class which sees if there are any members in the database with the supplied details, then returns a simple number to show how many results there are, but it isnt working and throwing the error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\classTest\classes\user_process.php on line 52 here is the class: require_once("db_mysql.php"); require_once("./init.php"); class emptyArgs extends Exception { function __toString() { return "<strong>Empty Arguments</strong>"; } } class user_process { public $user_name; public $password; public function login($user_name, $password) { try { if (empty($user_name) || empty($password)) { throw new emptyArgs(); } if ($user_name == "") { throw new emptyArgs(); } } catch (emptyArgs $e) { echo $e; echo "<p>Please Supply All Details Marked *</p>"; } echo $user_name; echo $password; $query = <<<QUERY SELECT COUNT(*) FROM ".TBL_PREFIX."members WHERE user_username = '$user_name' AND user_password = '$password' QUERY; $process = mysql_query($query); $result = mysql_num_rows($process); // Line 52 where the error originates return $result; } } and here is the call: $user = new user_process(); $user->login("username", "password"); All of the database details are correct and the values do match in the database. Where am i going wrong? Note that this class is just for testing and not actually used. Quote Link to comment https://forums.phpfreaks.com/topic/221950-query-within-class-failing/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 17, 2010 Share Posted December 17, 2010 Some error checking and error reporting/logging logic would tell you why the query is failing. Quote Link to comment https://forums.phpfreaks.com/topic/221950-query-within-class-failing/#findComment-1148525 Share on other sites More sharing options...
suma237 Posted December 17, 2010 Share Posted December 17, 2010 echo $query; $process = mysql_query($query)or die(mysql_error()); please check Quote Link to comment https://forums.phpfreaks.com/topic/221950-query-within-class-failing/#findComment-1148534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.