Jump to content

DELETE wont work :(


almightyegg

Recommended Posts

[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
Share on other sites

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
Share on other sites

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 here

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]
Link to comment
Share on other sites

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 this

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!";
}
?>
Link to comment
Share on other sites

[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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.