Reputation: 17
I am successfully selecting the data from database table, when ever I am trying to fetch that data in to an array with the help of mysql_fetch_array()
it's not storing anything into the array.
@session.start();
$name=$_SESSION['umailid'];
$chkname1 = "select * from ".USREG." where email='.$name.'";
echo $chkname1;
// it is printing like this:
// " select * from users_temp where email='[email protected].' "
// which means query was successful, above email is there in database table
$res1 = mysql_query($chkname1, $con) or die(mysql_error());
$chkresult1 = mysql_fetch_array($res1);
echo $chresult1['name']; //its not printing anything
if ($chkresult1) //it is storing null and entering into else block
{
echo "query successful";
}
else {
echo "query was not successful";
}
And the result is "query was not successful". I think everything is fine with my select query. Then why this mysql_fetch_array()
is not fetching the data?
Upvotes: 0
Views: 329
Reputation: 2543
In $chkname change to email = $name
(remove dot) or email = '$name'
And you are using mysql ,rather use mysqli or pdo sql
Upvotes: 3