First, if "$submit" is not set, then the "delete" statement will be
executed.  This will not return an array upon which mysql_fetch_array() will
act.  Therefore $result will not be valid.

-----Original Message-----
Sent: Monday, January 14, 2002 11:18 AM
Subject: [PHP-DB] Why the following error, yet it works anyway

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 -
    <meta name="generator" content="HTML Tidy, see" />
    <title>Dealer Bulletins, Simrad, Inc</title>
    <center><h2>Simrad Dealer Bulletins - Delete Screen</h2>
    <br /><strong><font color="red">NOTE: This is a permanent and 
                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'";
    $sql = "select news_id, bulletin_subject from dbulletins"; 
    $result = mysql_query($sql);
     while ($row = mysql_fetch_array($result)) 
     print "<tr>\n<td>Delete entry 
<a href="bulletin_admin.php">Back</a></center> 
Chip Wiegand
Computer Services
Simrad, Inc

"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!)

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to