Query Not working?

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
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Query Not working?

Post 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());
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Backticks are reserved for table and column names

Code: Select all

$query = ("SELECT * FROM `tenant_profile` WHERE `tenant_ID` = '$tenant_ID'");
rfigley
Forum Commoner
Posts: 70
Joined: Sun Apr 21, 2002 7:10 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

as Jcart said, columns and table names are put in backticks, while variables go in quotes.

` vs '
Post Reply