[SOLVED] Take a look -- I can't figure it out. (MySQL query)

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
siefkencp
Forum Commoner
Posts: 69
Joined: Thu Dec 16, 2004 8:50 am

[SOLVED] Take a look -- I can't figure it out. (MySQL query)

Post by siefkencp »

I have the following code I cant see a problem with but MySQL spits out an error when I try it. Check out below to see the code and the message...



Code: Select all

include 'c:\Intranet\phplib\header.php';
include 'c:\Intranet\phplib\mysql_connect.php';

$key = $_GETї'key'];

$student_array = mysql_query ("SELECT * FROM staff WHERE key = '$key'")
	or die ("Not Found" . mysql_error());
	
$row = mysql_fetch_array($student_array, MYSQL_ASSOC);
	$last = $rowї'Last'];
	$first = $rowї'First'];
	$OfficePhone = $rowї'OfficePhone'];
	$key = $rowї'key'];
	$add1 = $rowї'Address1'];
	$city = $rowї'City'];
	$HomePhone = $rowї'HomePhone'];
?>
I get this for my error but everything looks good in my query...
Not FoundYou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 164' at line 1
Last edited by siefkencp on Thu Jan 13, 2005 10:30 am, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"key" is a MySQL keyword. Try this query:

Code: Select all

SELECT * FROM `staff` WHERE `key` = '$key'
siefkencp
Forum Commoner
Posts: 69
Joined: Thu Dec 16, 2004 8:50 am

Post by siefkencp »

Good call, I didn't even think about that. Im all fixed thanks for the help.

Chris
Post Reply