0

See something wrong in my code? I can't get the update function to work.. weird thing is the rest works correctly, and the same code works 100% on another page.

<?php
include("config.php");

$id = $_GET['id'];

$number = $_GET['no'];

$result = mysql_query("SELECT * FROM comments WHERE commentid = '$id'")
or die(mysql_error());  

$row = mysql_fetch_array( $result );

mysql_query("update `comments` set like = like +1 where commentid = '$id'"); <--- only this here doesnt work
?>

And there is 1 line of html after that, a span tag getting some information out of the comments table. My 'like' column is set to int(11), so I don't see that being the problem.

Hope this isnt another innatention mistake :/

Thanks alot to anyone who can help me out!

This is the error

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 'like = like +1 where commentid = '61'' at line 1

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Alex Cane
  • 157
  • 1
  • 2
  • 9

1 Answers1

2

As EboMike posted, LIKE is a reserved keyword in MySQL.

You can either rename your column to something else that is not a keyword (preferred), or you can put a backtick (a backwards single quote) around it to tell MySQL it's a literal name.

Cyntech
  • 5,362
  • 6
  • 33
  • 47