Jump to content

if clause not working? mysql query not working? well something isn't working?


spiceydog

Recommended Posts

I have this script that is supposed to take the get data and then do some stuff. You will easily be able to tell what it's supposed to do because it's a very simple script. Here is my script:

<?php
$result = mysql_query("SELECT * FROM comments WHERE id = '$post' LIMIT 0, 1");
while($row = mysql_fetch_array($result)) {
   $cpost  = $row['post'];
   $cuser  = $row['user'];
   
$result2 = mysql_query("SELECT * FROM albuminfo WHERE post = '$cpost' GROUP BY albumname");
while($row2 = mysql_fetch_array($result2)) {
   $user  = $row2['user'];
   
if (($cuser == $username) || ($user == $username)) {
mysql_query("DELETE FROM comments WHERE id = '$post'");
header("Location: viewpost.php?id=$cpost");
}
else {
echo "<script language='JavaScript' type='text/javascript'>alert('Stop trying to delete comments that arent on your posts.'); 
          location = 'viewpost.php?id=$cpost';</script>";
exit;
}
?>

 

I also echoed the following and got the following results (i am logged in with the username "account"):

$cuser = account2

$user = account

$username = Account

$cpost = 4

 

Now it seems to me like this should work... but it just opens the popup and continue on it's way...

Archived

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

×
×
  • 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.