Page 1 of 1

Query Not working?

Posted: Sun Aug 21, 2005 8:27 am
by rfigley
Can anyone tell me what the problem, is with this?

Here is my output for:

tenant for Deletion: 1
Tenant ID: 00054

tenant for Deletion: 2 Tenant ID: 00054
(with the 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 '00054'' at line 1

for this code:
include('dbconnect.php');
echo "tenant for Deletion: 1" . $tenant_name . "<BR>Tenant ID: " . $tenant_ID . "<BR><BR>";


$query = ("SELECT * FROM `tenant_profile` WHERE `tenant_ID` = `$tenant_ID`");
echo "tenant for Deletion: 2 " . $tenant_name . "Tenant ID: " . $tenant_ID . "<BR><BR>";

$result = mysql_query($query) or die (mysql_error());

Posted: Sun Aug 21, 2005 8:28 am
by John Cartwright
Backticks are reserved for table and column names

Code: Select all

$query = ("SELECT * FROM `tenant_profile` WHERE `tenant_ID` = '$tenant_ID'");

Posted: Sun Aug 21, 2005 9:21 am
by rfigley
Oh, ok, thanks

Had been having troulbe between that, and now I get this with that correction:

Unknown column 'tenant_ID' = '00057'' in 'where clause'

Here is part of the table structure that involves that.

tenant_ID int(5) UNSIGNED ZEROFILL No auto_increment
client_ID varchar(4) latin1_swedish_ci No
client_name varchar(30) latin1_swedish_ci No
client_email varchar(20) latin1_swedish_ci No
month_filed char(2) latin1_swedish_ci

Posted: Sun Aug 21, 2005 9:23 am
by feyd
as Jcart said, columns and table names are put in backticks, while variables go in quotes.

` vs '