I have used the example (and some others) program but for some reason i don't seem to be able to read data from my database. Can someone help me to find out what is wrong.
The database is located at www(.)canary(.)co(.)za,
database name = canaryco_codes
table = towns
password = Lechwe01
fields = town-id, town, province, street, box, area
If you run www(.)canary(.)co(.)za/codes3 the result is:
"; echo "
town-id " "
town " "
province " "
street"; while(list($town-id,$town,$province,$street)= mysql_fetch_array($val)) { echo ""; echo "".$town-id.""; echo "".$town.""; echo "".$province.""; echo "".$street.""; echo ""; } echo ""; echo "
Done
n"; ?>
This is the sample program:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database</title>
</head>
<body>
<?php
//connect database
$con=mysql_connect("localhost","**********","********") or die(mysql_error());
// select database
mysql_select_db("canaryco_codes",$con);
//select values from towns table
$data="SELECT * FROM towns";
$val=mysql_query($data);
echo "<table border='1'>";
echo " <p>town-id " " <p>town " " <p>province " " <p>street";
while(list($town-id,$town,$province,$street)= mysql_fetch_array($val))
{
echo "<tr>";
echo "<td>".$town-id."</td>";
echo "<td>".$town."</td>";
echo "<td>".$province."</td>";
echo "<td>".$street."</td>";
echo "</tr>";
}
echo "</table>";
echo "<p>Done </p>n";
?>
</body>
</html>
Thanks a lot.