I have the following short web page to delete dealer bulletins from a
database. My page lists
all the bulletins in the database - id and subject. There is a text input
field to enter the bulletin
id number and hit the delete button, and the bulletin is deleted. It works
except after the submit
delete I get an error -
---------------------------------
Warning: Supplied argument is not a valid MySQL result resource in
/usr/local/apache/htdocs/bulletin_delete.php on line 35
-----------------------------------------
line 35 is the while statement.
Here is the complete page -
-----------------------------------------
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Dealer Bulletins, Simrad, Inc</title>
</head>
<body>
<center><h2>Simrad Dealer Bulletins - Delete Screen</h2>
<br /><strong><font color="red">NOTE: This is a permanent and
irreversible
delete! No second chances here!</font></strong></center>
<hr width="75%" noshade="noshade" />
<form action="bulletin_delete.php" method ="POST">
Enter the bulleting ID Number: <input type="text" name="newsid">
<input type="submit" name="submit" value="Delete"></form>
<table summary="" border="0" cellpadding="5" align="center" width="90%">
<?
$db = mysql_connect("localhost", "root")
or die ("Can't get the database server");
mysql_select_db("bulletins", $db) or die ("Can't get the database");
if (isset($submit)):
$sql = "delete from dbulletins where news_id = '$newsid'";
else:
$sql = "select news_id, bulletin_subject from dbulletins";
endif;
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
print "<tr>\n<td>Delete entry
<strong>".$row["news_id"]."</strong>? "
.$row["bulletin_subject"]."</td>\n</tr>\n";
}
?>
</table>
<center>
<a href="bulletin_admin.php">Back</a></center>
</body>
</html>
----------------------------------------
--
Chip Wiegand
Computer Services
Simrad, Inc
www.simrad.com
[EMAIL PROTECTED]
"There is no reason anyone would want a computer in their home."
--Ken Olson, president, chairman and founder of Digital Equipment
Corporation, 1977
(They why do I have 7? Somebody help me!)