Page 1 of 1

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

Posted: Thu Jan 13, 2005 10:17 am
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

Posted: Thu Jan 13, 2005 10:26 am
by feyd
"key" is a MySQL keyword. Try this query:

Code: Select all

SELECT * FROM `staff` WHERE `key` = '$key'

Posted: Thu Jan 13, 2005 10:29 am
by siefkencp
Good call, I didn't even think about that. Im all fixed thanks for the help.

Chris