I wish I could get this to work... it has not been able to work at all. I made the changes you have suggested and tried different variations concerning the results items and so far no dice. Here is my delete sql statement as of right now...
<?php require '../scripts/db.php'; $table_name = "cur_inv"; $sql = "DELETE FROM $table_name WHERE $id = 'id'"; $result = @mysql_query("$sql, $dbh") or die("Could not execute query, please try again later"); ?> I keep getting an error on the result portion, I have double, and triple checked my table names, my db connection (which has error checking on it so I know I am connecting fine). I am wondering would it be beneficial to actually put a select statement in for the database table? I would think declaring the variable would work fine. In any event I also changed the checkbox name to id to match the variable in the delete statement. For readability sake here is the form code as well.... <?php require '../scripts/db.php'; $result = mysql_query("SELECT * FROM cur_inv",$dbh) or die("Could not execute query, please try again later"); echo "<table border=\"0\" class=\"table-body\" width=\"100%\"><form name=\"rem_inv\" method=\"post\" action=\"done2.php3\"> <tr><td align=\"center\" colspan=\"3\"><font size=\"4\"><B>Current Inventory</B></font><hr color=\"333333\"></td></tr>"; $count = -1; while ($myrow = mysql_fetch_row($result)) { $count ++; echo "<tr><td width=\"30%\"><B>Type Of Car: </B></td><td>"; printf(mysql_result($result,$count,"car_type")); echo "</td><td><input type=\"checkbox\" name=\"id\" value=\"".$myrow[id]."\">remove</td> </tr>\n"; echo "rest of table and cell output"; } echo "<tr><td><input type=\"submit\" name=\"delete\" value=\"delete\"></td></tr></form></table>"; ?> "Gurhan Ozen" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Jas, > You still have cars as your checkbox name.. change it to id.. > and make sure that you assign $table_name to the table name you want to > delete from in your done2.php3 file.. > > Gurhan > > -----Original Message----- > From: jas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 21, 2002 3:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Errors Deleting... > > > Can someone tell me how I can find out why I am getting errors executing > queries when I try to delete items from a table? I have 2 files... > file 1. - Queries database, displays results with option to delete record > using a check box, code is as follows... > <?php > require '../scripts/db.php'; > $result = mysql_query("SELECT * FROM cur_inv",$dbh) or die("Could not > execute query, please try again later"); > echo "<table border=\"0\" class=\"table-body\" width=\"100%\"><form > name=\"rem_inv\" method=\"post\" action=\"done2.php3\"> > <tr><td align=\"center\" colspan=\"3\"><font size=\"4\"><B>Current > Inventory</B></font><hr color=\"333333\"></td></tr>"; > $count = -1; > while ($myrow = mysql_fetch_row($result)) { > $count ++; > echo "<tr><td width=\"30%\"><B>Type Of Car: </B></td><td>"; > printf(mysql_result($result,$count,"car_type")); > echo "</td><td><input type=\"checkbox\" name=\"cars\" > value=\"".$myrow[id]."\">remove</td> > </tr>\n"; > echo "<tr><td width=\"30%\"><B>Model Of Car: </B></td><td>"; > printf(mysql_result($result,$count,"car_model")); > echo "</td></tr>\n"; > echo "<tr><td width=\"30%\"><B>Year Of Car: </B></td><td>"; > printf(mysql_result($result,$count,"car_year")); > echo "</td></tr>\n"; > echo "<tr><td width=\"30%\"><B>Price Of Car: </B></td><td>$"; > printf(mysql_result($result,$count,"car_price")); > echo "</td></tr>\n"; > echo "<tr><td width=\"30%\"><B>VIN Of Car: </B></td><td>"; > printf(mysql_result($result,$count,"car_vin")); > echo "</td></tr><tr><td colspan=\"3\"><hr color=\"333333\"></td></tr>\n"; > } > echo "<tr><td><input type=\"submit\" name=\"delete\" > value=\"delete\"></td></tr></form></table>"; > ?> > file 2. - takes variable of checkbox and then queries db trying to delete > any record based on the id. code is as follows... > <?php > require '../scripts/db.php'; > $table_name = "cur_inv"; > $sql = @mysql_query("DELETE FROM $table_name WHERE $id = 'id'",$dbh) or > die("Could not execute query, please try again later"); > print("changes made"); > ?> > I have been trying everything under the sun and cannot get this to work. > please help. > Jas > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php