Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Other » PHP issue
Re: PHP issue [message #440914 is a reply to message #438943] Mon, 06 December 2010 10:00 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
OK, the problem here is simple. Your setting the a session variable with the comment ID in... except you load MULTIPLE comments, so each comment overwrites the ID the previous one set, so if you use this variable on page2 to delete a comment it will ALWAYS delete the last comment loaded.

You should instead pass the comment ID to be deleted as a parameter to the delete page and use the $_GET array to obtain it's value.


I have modified your code fragments below, look at the changes and you should be able to work out whats happening.


$commentquery = mysql_query("SELECT * FROM comments WHERE reciptent = '".$id."'ORDER BY TIMESTAMP DESC");
while($get_comment_array = mysql_fetch_array($commentquery))
{
$sender = $get_comment_array['sender'];
$senderid = mysql_query("SELECT * FROM members WHERE uid = '".$sender."'");
$memberarray = mysql_fetch_array($senderid);
$sendername = $memberarray['fullname'];
$commentid = $get_comment_array['commentid'];
$recepitent = $get_comment_array['reciptent'];
$message = $get_comment_array['message'];
$timeofwriting = $get_comment_array['TIMESTAMP'];
	echo "<div class='comments'>";	
	echo "<a style='color:blue;text-decoration:underline;' href='profile.php?id=".$sender."'>".$sendername."</a>" . " ". $message ." <a style='float:right' href='comment.php?type=member&action=del&amp;cid=".$commentid."'><img src='delmessage.jpg'/></a>"."<span style='font-size:12px;color:grey;'>".$timeofwriting. . "</span>";
	echo "</div>";
}
echo "<div class='comments'>";
$_SESSION['tid'] = $id;
//$id == $_GET['id']


page2.php (this is the deleting page)
if($_GET['type'] == "member" && $_GET['action'] == "del")
{
	mysql_select_db("user");
$cid = $_GET['cid'];
$delquery = mysql_query("DELETE FROM comments where commentid = '".$cid."' AND  sender = '".$uid."'OR reciptent = '".$uid."'")or die(mysql_error());	
header("Location: page1.php?id=".$tid."");
}




Also, I am interested to know where page2.php gets the values of $uid and $tid from, as they are not set in that code fragment. I assume you do set theirs value correctly elsewhere in the script?


http://steamsignature.com/card/1/76561197975867233.png
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GameSpy
Next Topic: Generals... AGAIN
Goto Forum:
  


Current Time: Tue Nov 26 09:58:05 MST 2024

Total time taken to generate the page: 0.01075 seconds