saloo Posted February 21, 2007 Share Posted February 21, 2007 hi. i have a form which is connected to my database and is accessible by the admin. admin can delete questions and add questions. my add question works but for some reason my delete does not work. here is my script editquizlist.php <HTML> <link rel="stylesheet" href="quiz.css" type="text/css"> <body><center> <P> </P> <B>Admin area - edit the quiz</B> <br><br> <table width="300" border="0" cellspacing="0" cellpadding="0"> <?php include("contentdb.php"); $result = mysql_query("SELECT id, question FROM $table ORDER BY id",$db); echo "<table>"; while ($row = mysql_fetch_array($result)) { $alternate = ""; $id = $row["id"]; $question = $row["question"]; if ($alternate == "1") { $color = "#ffffff"; $alternate = "2"; } else { $color = "#efefef"; $alternate = "1"; } echo "<tr bgcolor=$color><td>$id:</td><td>$question</td><td>[ <a href='editquiz.php?id=$id'>edit</a> ]</td><td>[ <a href='deletequiz.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete</a> ]</td></tr>"; } echo "</table>"; ?> <br> <br> <a href="editquiz.php">Add a new question to the quiz</a></td> </tr> </table> <br> <br> <a href="quizinfo.php">See the full quiz table</a> </center> </body> </HTML> here is my deletequiz.php <HTML> <link rel="stylesheet" href="quiz.css" type="text/css"> <center> <?php include("contentdb.php"); mysql_query("DELETE FROM $table WHERE id=$id",$db); echo "<P> </P>"; echo "<B>Admin area - delete a quiz question<br><br></B>"; echo "Question deleted<br><br>"; echo "<a href='editquizlist.php'>Back to list of quiz questions</a>"; ?> </center> </HTML> it looks fine to me. any help will be really appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 Where is $id being set? Try outputting that string via: echo "DELETE FROM $table WHERE id=$id"; Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2007 Share Posted February 21, 2007 $sql = "DELETE FROM $table WHERE id=$id"; mysql_query($sql,$db) OR die('SQL: '.$sql.' - Error: '.mysql_error()); You never define $id, it needs to be $id = $_GET['id']; before the query, since you can't count on register_globals being on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.