Allow users to update account

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
merchhaus
Forum Newbie
Posts: 9
Joined: Wed Jan 12, 2011 4:41 pm

Allow users to update account

Post 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));
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Allow users to update account

Post 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.
Post Reply