update query error

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
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

update query error

Post by ianhull »

anyone see why this does not work?

Code: Select all


<?php session_start();
    
	if($_SESSION['user']['user_group'] == 'Administrator'){
	} else {
	echo '<meta http-equiv="refresh" content="0;URL=un-authorised.php" />';
	exit();
	};
	include_once($_SERVER['DOCUMENT_ROOT'].'/includes/connection.php');
	
	$title = $_POST['title'];
	$firstname = $_POST['firstname'];
	$surname = $_POST['surname'];
	$email = $_POST['email'];
	$location = $_POST['location'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$status = $_POST['status'];
	$id = $_POST['id'];
	
	$updateUsers = mysql_query("UPDATE users SET title='$title', firstname='$firstname' surname='$surname', email='$email', location='$location', username='$username', password='$password', status='$status' WHERE id='$id'"
) 
or die(mysql_error());

	
	
	echo '<meta http-equiv="refresh" content="0;URL=user_updated.php" />
';
?>

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 'surname='*****', email='**********', location='**********' at line 1

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Descriptive subjects

Post by feyd »

I've removed "plz help" from the subject. Why?
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

:idea: Appologies feyd!
smudge
Forum Contributor
Posts: 151
Joined: Sun May 20, 2007 12:13 pm

Post by smudge »

You need a comma between firstname='$firstname' and surname='$surname', so:

Code: Select all

firstname='$firstname', surname='$surname'
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

thanks mate,

so simple sometimes,

thanks again
Post Reply