Page 1 of 1

Allow users to update account

Posted: Mon May 16, 2011 10:45 am
by merchhaus
I am trying to query info from a database to allow users to update their account. The error I am getting is: Unknown column 'Smith' in 'where clause'. "Smith" is the correct $last_name for the user

Code: Select all

$user_id = (isset($_GET['id'])) ? $_GET['id'] : '';
$last_name = (isset($_GET['name'])) ? $_GET['name'] : '';
	
$query = 'SELECT
	username, first_name, last_name, email, company, user_type
FROM
  site_user u JOIN site_user_info i ON u.user_id = i.user_id
WHERE
 u.user_id = ' . $user_id . '
 AND
 last_name = ' . $last_name;
$result = mysql_query($query, $db) or die(mysql_error($db));

Re: Allow users to update account

Posted: Mon May 16, 2011 11:16 am
by Celauran
You'll need quotes around Smith for sure.

Code: Select all

...
AND last_name = \'' . $last_name . '\'';
You could also try to echo the query to see what looks amiss.