Jump to content

post to delete


redarrow

Recommended Posts

advance thank you.

i want to use a link to delete a database entry but not a form how do i do that cheers.


this comes from member page

[code]

<a href='delete_message.php?&id=".$record['sent_id']."'>Delete</a>

[/code]

delete.php seprate page
[code]
<? session_start();

$db=mysql_connect("localhost" , "xxx" , "xxx");
mysql_select_db("promotor",$db);


$query="delete member_message where id=".$_GET['id']." ";


$result=mysql_query($query);

echo "deleted";

?>
[/code]
Link to comment
Share on other sites

As always, use mysql_error() to check if MySQL returns any error if it doesn't work. Remember that strings must always have quotes, so if your id is a string, use them:

Mainly your query is incorrect:
[code]$query="DELETE FROM member_message WHERE id='{$_GET['id']}'";[/code]
Link to comment
Share on other sites

if you want to only delete the members message of that users id but if time matches

cheers.

ps. it deletes all user rows to the id at the moment

example.
[code]
<? session_start();

$db=mysql_connect("localhost" , "xxx" , "xxx");
mysql_select_db("promotor",$db);


$id=$_GET['id'];

if($_GET["cmd"]=="delete")
{


$query="delete from member_messages where time='$time' and id='$id' ";
echo $query;

$result=mysql_query($query);

echo "deleted";

}

?>
[/code]

echoed query
[code]
delete from member_messages where time='05:49:09' and id='0008'
deleted
[/code]
Link to comment
Share on other sites

Your query should work... There is the "AND" keyword, this should make it delete only rows with the specified id AND time.

Are you sure this query deletes messages ignoring the time condition?

700th post [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
Link to comment
Share on other sites

[!--quoteo(post=382750:date=Jun 12 2006, 04:57 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 12 2006, 04:57 AM) [snapback]382750[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Your query should work... There is the "AND" keyword, this should make it delete only rows with the specified id AND time.

Are you sure this query deletes messages ignoring the time condition?

700th post [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
[/quote]

yes it deletes all messages from that users id but with time in place dosent delete at all.
Link to comment
Share on other sites

[!--quoteo(post=382756:date=Jun 11 2006, 10:15 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 11 2006, 10:15 PM) [snapback]382756[/snapback][/div][div class=\'quotemain\'][!--quotec--]
yes it deletes all messages from that users id but with time in place dosent delete at all.
[/quote]
And that is the expect behavior, I guess.

When there is time in place and nothing is deleted, this probably means no rows matching your criteria were found.
What is the timestamp format you are using?
Link to comment
Share on other sites

working fine like this


[code]
<? session_start();

$db=mysql_connect("localhost" , "root" , "admin");
mysql_select_db("promotor",$db);


$time=$_GET['time'];

$id=$_GET['id'];

if($_GET["cmd"]=="delete")
{


$query="delete from member_messages where time='$time' ";
echo $query;

$result=mysql_query($query);

echo "deleted";

}

?>
[/code]

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.