lebexpress Posted July 22, 2008 Share Posted July 22, 2008 Hello, I am trying to get the number of rows being retrieved to equal to 1 after running this query : if ($e && $p) { //this condition passed the test $query = "SELECT user_id , first_name FROM customer WHERE (email='$e' AND pass = SHA('$p')) AND active IS NULL"; $result = mysql_query ($query) or trigger_error("Query: $query\n <br />MySQL Error: " . mysql_error()); $num_rows =mysql_num_rows($result); echo"the num of rows = $num_rows<br>"; } here's where I keep getting a 0, I know that all my variables are correct, and for some reason it's never changing. I need to pass that so I can : if($num_rows ==1) { $row = mysql_fetch_array($result,MYSQL_NUM); mysql_free_result($result); mysql_close(); $_SESSION['first_name']=$row[1]; echo "{$_SESSION['first_name']} <br>"; // it's not getting here, I need to get that for my login session. } Please help! Quote Link to comment https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/ Share on other sites More sharing options...
.josh Posted July 22, 2008 Share Posted July 22, 2008 echo $query and try running that directly in phpmyadmin, do you get the desired result? Quote Link to comment https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/#findComment-596205 Share on other sites More sharing options...
lebexpress Posted July 22, 2008 Author Share Posted July 22, 2008 thanks for the reply, Unfortunately i got: SELECT user_id , first_name FROM customer WHERE (email='[email protected]' AND pass = SHA('hello123')) AND active IS NULL I know that the email and the password are correct. Something else I can do? Quote Link to comment https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/#findComment-596252 Share on other sites More sharing options...
huesped214 Posted July 22, 2008 Share Posted July 22, 2008 you always can try to simplify the WHERE, try first email and active, if your row is there you know the problem is the pass and so on, try some combinations Quote Link to comment https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/#findComment-596271 Share on other sites More sharing options...
lebexpress Posted July 22, 2008 Author Share Posted July 22, 2008 It Worked! The problem was with the NULL, I had it sat up by default to "Not Null" and when I used to see the cell empty, I used to think that it's null, but actually the space does not mean null. Thank you very much for your help! huesped214 & Crayon Violent Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/#findComment-596355 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.