mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\wishlist\admlist.php on line 39 & 64 & 89
Jeg har brug for lidt hjælp. Jeg er ved at lave min årsopgave i programmering og jeg laver en hjemmeside. Jeg har noget kode her og den kommer ud med ovenstående fejl men jeg kan ikke finde fejlen, alt ser ud til at være i orden og listen den finder eksisterer. Hvis i kan hjælpe må i gerne skrive det som svar så jeg kan give point bag efter.<html>
<head>
<link rel="stylesheet" type="text/css" href="tema.css">
</head>
<body>
<table>
<tr>
<td class="admlist">
<table class="admlist">
<tr>
<td class="admlist-1">
<h1 class="admlist-header">Wish</h1>
</td>
<td class="admlist-2">
<h1 class="admlist-header">Date</h1>
</td>
<td class="admlist-3">
<h1 class="admlist-header">Description</h1>
</td>
<td class="admlist-4">
<h1 class="admlist-header">Delete</h1>
</td>
</tr>
<?
$host = "localhost";
$username = "root";
$password = "hda99zkk"; //Først vil vi logge ind i databasen, men inden da skal vi have defineret forskellige ting
$database = "wishlist";
$table = $_REQUEST["username"];
MySQL_connect("$host", "$username", "$password") or die(mysql_error()); //Derefter forbinder vi til både hotellet
MySQL_select_db("$database") or die(mysql_error());
$sql = "SELECT * FROM $table WHERE hol = High";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)){
?>
<tr>
<td>
<p><? echo $rows['wish']; ?></p>
</td>
<td>
<p><? echo $rows['date']; ?></p>
</td>
<td>
<p><? echo $rows['description']; ?></p>
</td>
<td>
<input type="text" class="nodisplay" value="<? echo $rows["wish"]; ?>" name="wish">
<input type="text" class="nodisplay" value="<? echo $table; ?>" name="username">
</td>
</tr>
<?
}
$sql = "SELECT * FROM $table WHERE hol = middle";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)){
?>
<tr>
<td>
<p><? echo $rows['wish']; ?></p>
</td>
<td>
<p><? echo $rows['date']; ?></p>
</td>
<td>
<p><? echo $rows['description']; ?></p>
</td>
<td>
<input type="text" class="nodisplay" value="<? echo $rows["wish"]; ?>" name="wish">
<input type="text" class="nodisplay" value="<? echo $table; ?>" name="username">
</td>
</tr>
<?
}
$sql = "SELECT * FROM $table WHERE hol = low";
$result = mysql_query($sql);
while ($rows = mysql_fetch_array($result)){
?>
<tr>
<td>
<p><? echo $rows['wish']; ?></p>
</td>
<td>
<p><? echo $rows['date']; ?></p>
</td>
<td>
<p><? echo $rows['description']; ?></p>
</td>
<td>
<input type="text" class="nodisplay" value="<? echo $rows["wish"]; ?>" name="wish">
<input type="text" class="nodisplay" value="<? echo $table; ?>" name="username">
</td>
</tr>
<?
}
?>
<table>
<form action="insert.php" method="post">
<tr>
<td>
<p>What you wish for</p>
</td>
<td>
<input type="text" name="wish">
</td>
</tr>
<tr>
<td>
<p>How high on the list do you want it</p>
</td>
<td>
<select>
<option name="hol" value="high">Higher</option>
<option name="hol" value="middle">Middle</option>
<option name="hol" value="low">Lower</option>
</select>
</td>
</tr>
<tr>
<td>
<p>Short description of the wish</p>
</td>
<td>
<textarea cols="50" rows="10" name="description"></textarea>
</td>
</tr>
<input type="text" class="nodisplay" value="<? echo $table; ?>" name="list"></input>
</form>
</table>
</table>
</td>
</tr>
</table>
</body>
</html>