Jump to content


Photo

Syntax error


  • Please log in to reply
1 reply to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 22 March 2006 - 09:41 PM

Hi all

Why do I get a syntax error when using the sql statement


if ($_GET['action'] == "add")

{    
$sql ="UPDATE users SET type = 4 WHERE id = $id";
@mysql_query($sql, $connection) or die(mysql_error());

}

I have a action also to delete a row which seems to work fine.

Thanks in advance

Ed

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 22 March 2006 - 09:55 PM

Are you sure you have a value for $id, or is your query

$sql ="UPDATE users SET type = 4 WHERE id = ";

As well as outputting mysql_error(), echo the $sql also.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users