Page 1 of 1

update query error

Posted: Tue Jun 05, 2007 8:53 am
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

Descriptive subjects

Posted: Tue Jun 05, 2007 8:58 am
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.

Posted: Tue Jun 05, 2007 9:00 am
by ianhull
:idea: Appologies feyd!

Posted: Tue Jun 05, 2007 9:01 am
by smudge
You need a comma between firstname='$firstname' and surname='$surname', so:

Code: Select all

firstname='$firstname', surname='$surname'

Posted: Tue Jun 05, 2007 9:15 am
by ianhull
thanks mate,

so simple sometimes,

thanks again