Jump to content


Photo

post to delete


  • Please log in to reply
6 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 June 2006 - 03:44 AM

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


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


delete.php seprate page
<? 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";

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 12 June 2006 - 04:01 AM

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:
$query="DELETE FROM member_message WHERE id='{$_GET['id']}'";

~ D Kuang

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 June 2006 - 04:45 AM

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.
<? 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";

}

?>

echoed query
delete from member_messages where time='05:49:09' and id='0008' 
deleted 

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 12 June 2006 - 04:57 AM

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\" /]
~ D Kuang

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 June 2006 - 05:15 AM

[!--quoteo(post=382750:date=Jun 12 2006, 04:57 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 12 2006, 04:57 AM) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 12 June 2006 - 05:18 AM

[!--quoteo(post=382756:date=Jun 11 2006, 10:15 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 11 2006, 10:15 PM) View Post[/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?
~ D Kuang

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 12 June 2006 - 05:25 AM

working fine like this


<? 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";

}

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users