hi,

I'm using

GLOBAL $db, $table;
$id = trim($id);
$id = (int) ceil($id);
$currentviews = trim($currentviews);
//
$query = mysql_query("UPDATE $table SET viewed = '$currentviews' WHERE index = '$id' LIMIT 1");

but I keep getting this error

"You have an error in your SQL syntax near 'index = '6' LIMIT 1' at line 1"

I thougt it might be that my $id is a string, and not a number?

any ideas?
boombanguk

    I thought it might be that my $id is a string, and not a number?

    So why not change it to a number? You've made sure it's a number in code before, you then turn it back into a string by adding the quotes in the SQL statement.

      boombanguk wrote:

      hi,

      I'm using

      GLOBAL $db, $table;
      $id = trim($id);
      $id = (int) ceil($id);
      $currentviews = trim($currentviews);
      //
      $query = mysql_query("UPDATE $table SET viewed = '$currentviews' WHERE index = '$id' LIMIT 1");

      but I keep getting this error

      "You have an error in your SQL syntax near 'index = '6' LIMIT 1' at line 1"

      I thougt it might be that my $id is a string, and not a number?

      any ideas?
      boombanguk

      I agree... remove the quotes in the SQL statement...

      try this:

      $query = mysql_query("UPDATE $table SET viewed = '$currentviews' WHERE index=$id LIMIT 1");
      
        Write a Reply...