For the code below i am trying to get the gender value in gen then store it in $gender but i am getting wrong output. I am getting Resource id #8 as my output instead of male or female.
What shall i do to get the gender value and store it in $gender with use of minimal coding.
$gender=mysql_query("SELECT `gender` as gen FROM `register` WHERE `reg_id` = 'reg252'");
echo $gender;
One way i can do is by calling something like the way below -
$gender=mysql_query("SELECT `gender` FROM `register` WHERE `reg_id` = 'reg252'");
while($erow = mysql_fetch_array($gender))
{
echo $erow['gender'];
}
mysql_*functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.mysql_queryreturns a result set resource, and you have figured out yourself how to get results from that result set. That's the way it works.echo $erow['gen'];as genis removed