Update Row If IP = IP in database
Posted: Sun Oct 22, 2006 2:33 pm
Hello,
I have a comment system that displays comments. It displays a butto, the button is to delete the comment, it is only shown if you wrote that comment.
I want to update a field in my database for the comment the person picked to delete.
The field that is updated is called show. If it equals 1 then the comment will show up, if it equals 0 then the comment will not show up.
I want to make sure that the comment being deleted is by the person who wrote it.
The script I thought would work is below:
It gives me,
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Basically.
I have a comment system that displays a button to people who wrote the comment, under their comment. when they click the comment, I want it to update a field on thier comment row in my database. I want it to update if it is really them, I wanna check if its them by their email address.
Thank You.
I have a comment system that displays comments. It displays a butto, the button is to delete the comment, it is only shown if you wrote that comment.
I want to update a field in my database for the comment the person picked to delete.
The field that is updated is called show. If it equals 1 then the comment will show up, if it equals 0 then the comment will not show up.
I want to make sure that the comment being deleted is by the person who wrote it.
The script I thought would work is below:
Code: Select all
<?
$username2= "muot_report";
$password2= "password";
$database2= "muot_report";
$connection2 = mysql_connect('localhost',$username2,$password2);
mysql_select_db($database2);
$id = $_POST['id'];
$ip = $_POST['ip'];
$sql4 = "SELECT * FROM `comments` WHERE ip =".$ip;
$result4 = mysql_query($sql4) or die(mysql_error());
while($row4 = mysql_fetch_array($result4)) {
if($ip = $row4['ip']){
mysql_query('UPDATE comments set `show` = 0 WHERE `id` ='.$id);
}
}
mysql_close($connection2);
?>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Basically.
I have a comment system that displays a button to people who wrote the comment, under their comment. when they click the comment, I want it to update a field on thier comment row in my database. I want it to update if it is really them, I wanna check if its them by their email address.
Thank You.