Find jobs - Web Hosting - Find jobs - Pet Store - Debt Consolidation

PDA

View Full Version : Showing Results Of A Query Through Php Script


progfrog
Dec 9th 2008, 6:32 am
hI!

I do not know what is wrong with this code- because i don't get the results on screen as i wrote in the code:


$rt=mysql_query("SELECT name FROM students");
if(!$rt)
echo "ERROR: error occured in MySQL query."; // if any error is there that will be printed to the
else
{
echo "connected successfully to query";
while ($row=mysql_fetch_array($rt))
{
echo "name: {$row['name'] }".
}
}
mysql_close($mysql_link);
?>

Need your help

Progfrog

crivion
Dec 9th 2008, 7:54 am
try like this
$rt=mysql_query("SELECT name FROM students");
if(!$rt)
echo "ERROR: error occured in MySQL query."; // if any error is there that will be printed to the
else
{
echo "connected successfully to query";
while ($row=mysql_fetch_array($rt))
{
echo "name: {$row['name'] }";
}
}
mysql_close($mysql_link);
?>

kapinder
Dec 9th 2008, 9:25 am
Change the below code
echo "name: {$row['name'] }".

to
echo "name: {$row['name'] }";

octalsystems
Dec 9th 2008, 9:45 am
change these lines and hopefully it ill work

$rt=mysql_query("SELECT name FROM students"); => $rt=mysql_query("SELECT `name` FROM students");
echo "name: {$row['name'] }"; => echo "name: {$row[name] }";