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?? Quote Link to comment 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 $ Quote Link to comment 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 :-[ Quote Link to comment 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. Quote Link to comment 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] Quote Link to comment 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. Quote Link to comment 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); Quote Link to comment 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 ??? Quote Link to comment 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. Quote Link to comment 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!";}?> Quote Link to comment 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! Quote Link to comment 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] Quote Link to comment 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? Quote Link to comment 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 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.