jas4 Posted July 30, 2007 Share Posted July 30, 2007 Hi hopefully you can help me: I'm trying to run a query and run it through a function to validate before it gets near my database. the error I get is: An error has occured in script 'C:\wamp\www\other\login.php' on line '19' mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given The query section is: (the line with the wrong syntax is in this part(half way down) $memberEmail =escape_data($_POST['loginEmail']); $memberPassword = escape_data($_POST['loginPassword']); $query =("SELECT memberid, memail, mfirstName, mactive FROM members WHERE memail = $memberEmail AND mpassword = ". (md5($memberPassword))); $result = mysqli_query($dbc,$query); if (mysqli_num_rows($result) == 1) { $row = mysqli_fetch_assoc($result); if($row['mactive'] == 1) { session_start(); $_SESSION['id'] = $row['memberid']; $_SESSION['logged_in'] = TRUE; header("Location: success.php"); } and the function in the config file that I made is: function escape_data($data){ //Need the connection: global $dbc; //Address the magic quotes. if(ini_get('magic_quotes_gpc')){ $data =stripslashes($data); } //Trim and escape: return mysqli_real_escape_string($dbc, trim($data)); } //End of escape_data() function I'm sure the syntax is slightly wrong, but I just cant figure out why its not being accepted Quote Link to comment Share on other sites More sharing options...
ViN86 Posted July 30, 2007 Share Posted July 30, 2007 An error has occured in script 'C:\wamp\www\other\login.php' on line '19' mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given the $result being passed is not a mysql query result (so the error msg says...) change this... $result = mysqli_query($dbc,$query); to... $result = mysqli_query($dbc,$query) or die(mysqli_error()); and see if it spits out an error. Quote Link to comment Share on other sites More sharing options...
jas4 Posted July 30, 2007 Author Share Posted July 30, 2007 erm its expecting a paramater. I've tried a few ($result,$query,$dbc,$error) but their not being accepted?? An error has occured in script 'C:\wamp\www\other\login.php' on line '16' mysqli_error() expects exactly 1 parameter, 0 given Quote Link to comment Share on other sites More sharing options...
calabiyau Posted July 30, 2007 Share Posted July 30, 2007 Try changing your query line to this $query ="SELECT memberid, memail, mfirstName, mactive FROM members WHERE memail = '".$memberEmail."' AND mpassword = '". (md5($memberPassword)))."'"; Quote Link to comment Share on other sites More sharing options...
jas4 Posted July 30, 2007 Author Share Posted July 30, 2007 problem solved. Thats so frustrating when it was something so simpe and you spend ages trying to fix it, but its fixed so i'm happy now. thanks Quote Link to comment 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.