alen Posted December 15, 2006 Share Posted December 15, 2006 I made this script that's supposed to delete a row when I click on one of the news titles..I added two threads, Hello world and Test.I simply want to delete Test. But when I click on the link nothing happends.Here's the code:http://anigma.sitees.com/delete.txt Quote Link to comment Share on other sites More sharing options...
Eric_Ryk Posted December 15, 2006 Share Posted December 15, 2006 Normally I don't do this but its easier than typing out all the instructions:[code]<html><body><? mysql_connect("localhost","nancy","ehgxsjhn"); mysql_select_db("nancy"); if(!isset($_GET["cmd"])) { $result = mysql_query("select * from news"); while($r=mysql_fetch_array($result)) { $title=$r["title"]; $id=$r["id"]; echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>"; echo "<br>"; }}if($_GET["cmd"]=="delete"){ $sql = "DELETE FROM news WHERE id=" . $_GET["id"]; $result = mysql_query($sql); echo "Row deleted!";}?></body></html>[/code]Try that out. Quote Link to comment Share on other sites More sharing options...
btherl Posted December 15, 2006 Share Posted December 15, 2006 A good first step is to check all your mysql_() functions for errors, like this:[code=php:0]mysql_query("select * from news") or die("Error: " . mysql_error());[/code]Add something similar to mysql_connect() and mysql_select_db() Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 15, 2006 Share Posted December 15, 2006 change:[code]if('$cmd'=="delete")[/code]to[code]if($cmd=="delete")[/code] 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.