<?php
$droll=$_SESSION['roll'];
$sql=" SELECT name FROM hostel_register WHERE roll=$droll";
$result=mysql_query($sql);
echo $result;
?>
This code instead of returning name returns value "Resource id #5" everytime. Can someone help?
<?php
$droll=$_SESSION['roll'];
$sql=" SELECT name FROM hostel_register WHERE roll=$droll";
$result=mysql_query($sql);
echo $result;
?>
This code instead of returning name returns value "Resource id #5" everytime. Can someone help?
You forgot to fetch your results
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo $row['name'];
Please, don't use mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
While fetching the records use a while loop :
<?php
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
echo $row['name'];
}
?>