What am I doing wrong?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

What am I doing wrong?

Post by Goofan »

Currently the code below gets an error message:
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 'WHERE id='1'' at line 2

Code: Select all

include_once("DB_Class.php");
		$db = new database();
		$mydb = "UPDATE my_research SET bet='" .$bet ."',
				WHERE id='" .$id ."'"; 
		$db->dbquery($mydb);
I got almost an identical query call on another page working perfectly. Why isn't this working?

(Sorry for thee vague information writing on my way out)

Regards,
Thomas
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: What am I doing wrong?

Post by social_experiment »

Code: Select all

 $mydb = "UPDATE my_research SET bet='" .$bet ."', WHERE id='" .$id ."'";
The , before the WHERE clause is causing the problem
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply