Jump to content

mysql query & php


lebexpress

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/115960-mysql-query-ampamp-php/
Share on other sites

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.