Jump to content

Archived

This topic is now archived and is closed to further replies.

redarrow

post to delete

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]

Share this post


Link to post
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]

Share this post


Link to post
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]

Share this post


Link to post
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\" /]

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.