mysql fetch problem
Hej alle..Mit script ser sådan her ud:
<html>
<head>
<title>
Mysql phonelist
</title>
<link rel = "stylesheet" type = "text/css" href = "style.css">
</head>
<body>
<?
//make the database connection
$conn = mysql_connect("localhost", "", "");
mysql_select_db("database1", $conn);
//create a query
$sql = "SELECT * FROM phonelist";
$result = mysql_query($sql, $conn);
print "<table border = 1>\n";
//get field names
print "<tr>\n";
while ($field = mysql_fetch_field($result)){
print " <th>$field->name</th>\n";
} // end while
print "</tr>\n\n";
//get row data as an associative array
while ($row = mysql_fetch_assoc($result)){
print "<tr>\n";
//look at each field
foreach ($row as $col=>$val){
print " <td>$val</td>\n";
} // end foreach
print "</tr>\n\n";
}// end while
print "</table>\n";
?>
</body>
</html>
?>
Men jeg modtager følgende fejl:
Warning: mysql_fetch_field(): supplied argument is not a valid MySQL result resource in /home/tobias/public_html/Test/mysql.php on line 24
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/tobias/public_html/Test/mysql.php on line 30
?>
Nogen der kan se sig ud af dette?
Mvh Tobias F. petersen