almightyegg Posted November 6, 2006 Share Posted November 6, 2006 [code=php:0]<?$mb = mysql_query("SELECT * FROM replies") or die(mysql_error());$id = mysql_fetch_array($mb);$GET = $id['id'];$view = "SELECT * FROM replies WHERE id = '{$_GET['id']}' LIMIT 1";$view2 = mysql_query($view);$reply = mysql_fetch_assoc($view2);//some other code in here which doesnt have anything to do with this....if(!$step){?><form name="form1" method="post" action="rdelete.php?step=change">Are you sure you want to delete reply <? echo $reply[id]; ?>?<input type="submit" name="Submit" value="Confirm" /></p></form><br><?}elseif($step=="change"){$deletereply = mysql_query("DELETE FROM replies WHERE id = '{reply['id']}'");echo "$reply[id] was deleted!";}?>[/code]it doesnt delete.....have i missed something?? Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/ Share on other sites More sharing options...
trq Posted November 7, 2006 Share Posted November 7, 2006 [quote]have i missed something??[/quote]Yes. Take a close look at your DELETE query. Your missing a $ Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-120680 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 doesnt delete still :([code=php:0]<?if(!$step){?><form name="form1" method="post" action="rdelete.php?step=change">Are you sure you want to delete reply <? echo $reply[id]; ?>?<input type="submit" name="Submit" value="Confirm" /></p></form><br><?}elseif($step=="change"){$deletereply = mysql_query("DELETE FROM replies WHERE id = '{$reply['id']}'");echo "The reply was deleted!";}?>[/code]I must have missed something else too :-[ Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121099 Share on other sites More sharing options...
Orio Posted November 7, 2006 Share Posted November 7, 2006 Look at this-[code]$GET = $id['id'];$view = "SELECT * FROM replies WHERE id = '{$_GET['id']}' LIMIT 1";[/code]Once it's $GET and once it's $_GETOrio. Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121104 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 nope still no change ??? this is very odd...[code=php:0]<?$mb = mysql_query("SELECT * FROM replies") or die(mysql_error());$id = mysql_fetch_array($mb);$GET = $id['id'];$view = "SELECT * FROM replies WHERE id = '{$GET['id']}' LIMIT 1";$view2 = mysql_query($view);$reply = mysql_fetch_assoc($view2);$tags = array('{MEM_ID}', '{MEM_USERNAME}', '{MEM_CLUTCH}');$vals = array($mem['id'], $mem['username'], $mem[clutch]);$qlink['quicklinks'] = str_replace($tags, $vals, $qlink['quicklinks']);echo "$qlink[quicklinks]";//Some separate code hereif(!$step){?><form name="form1" method="post" action="rdelete.php?step=change">Are you sure you want to delete reply <? echo $reply[id]; ?>?<input type="submit" name="Submit" value="Confirm" /></p></form><br><?}elseif($step=="change"){$deletereply = mysql_query("DELETE FROM replies WHERE id = '{$reply['id']}'");echo "The reply was deleted!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121114 Share on other sites More sharing options...
Orio Posted November 7, 2006 Share Posted November 7, 2006 Maybe there's a problem with the variable $reply['id']. How is it set?Orio. Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121121 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 $view = "SELECT * FROM replies WHERE id = '{$GET['id']}' LIMIT 1";$view2 = mysql_query($view);$reply = mysql_fetch_assoc($view2); Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121126 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 right the delete works now...but it is selecting bottom row number and deleting the row with id that equals the number of rows ??? Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121137 Share on other sites More sharing options...
Orio Posted November 7, 2006 Share Posted November 7, 2006 Because you didnt specify what row to select, and by doing this:[code]$mb = mysql_query("SELECT * FROM replies") or die(mysql_error());$id = mysql_fetch_array($mb);$GET = $id['id'];[/code]you get the id of the first row.Orio. Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121142 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 thanks...it now recognises the row etc...but doesnt delete it ???[code=php:0]<?$id = $_GET['id'];$view = "SELECT * FROM replies WHERE id = '$id' LIMIT 1";$view2 = mysql_query($view);$reply = mysql_fetch_assoc($view2);\\other code..not to do with thisif(!$step){?><form name="form1" method="post" action="rdelete.php?step=change">Are you sure you want to delete reply <? echo $id; ?>?<input type="submit" name="Submit" value="Confirm" /></p></form><br><?}elseif($step=="change"){$deletereply = mysql_query("DELETE FROM replies WHERE id = '$id'");$delrep = mysql_query($deletereply);echo "The reply was deleted!";}?> Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121150 Share on other sites More sharing options...
trq Posted November 7, 2006 Share Posted November 7, 2006 Post your entire code again, and try some debugging! Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121174 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 [code=php:0]<?$id = $_GET['id'];$view = "SELECT * FROM replies WHERE id = '$id' LIMIT 1";$view2 = mysql_query($view);$reply = mysql_fetch_assoc($view2);if(!$step){?><form name="form1" method="post" action="rdelete.php?step=change">Are you sure you want to delete reply <? echo $id; ?>?<input type="submit" name="Submit" value="Confirm" /></p></form><br><?}elseif($step=="change"){$deletereply = mysql_query("DELETE FROM replies WHERE id = '$id'");$delrep = mysql_query($deletereply);echo "The reply was deleted!";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121176 Share on other sites More sharing options...
trq Posted November 7, 2006 Share Posted November 7, 2006 Sorry but that code makes little sense. For starters... what do you need the SELECT at the top for? Next, your form asks if your user is sure they want to delete $id, but if they submit the form $id is never passed to the script again for use in your DELETE. where do you define $step? Why are you using an elseif when an else is sufficient? Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121184 Share on other sites More sharing options...
almightyegg Posted November 7, 2006 Author Share Posted November 7, 2006 ive made it work. thanks :) I used the advice you gave about hidden field (value=$id) and so it now works :D Link to comment https://forums.phpfreaks.com/topic/26388-delete-wont-work/#findComment-121197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.