I'm using 1.7.2. and I got a problem in my coding, I'm very fresh in coding,but I try this code in the old version before, it works! But can't work in the new version.
- Code: Select all
<?php
$conn = mysql_connect("localhost","root","");
mysql_select_db("userdb");
$result = mysql_query("select * from tb_book",$conn);
echo "<table border=1><tr>";
if($field = mysql_fetch_field($result)){
echo "<td> ".$field->name." </td>";
}
echo "</tr>";
if($rows = mysql_fetch_row($result)){
echo "<tr>";
for($i=0; $i<count($rows);$i++)
echo "<td> ".$rows[$i]."</td>";
}
echo "</tr></table>";
?>
Warning: mysql_fetch_field() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sql\1.php on line 26
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sql\1.php on line 30
the db connection is fine, how can i fix this problem?
many thanks
hempseed