advancedfuture Posted November 7, 2008 Share Posted November 7, 2008 So I have a test godaddy account I use for developement before I bring my client sites live. It runs PHP5.x and MySQL 4.1: On my test server I run a query: SELECT DISTINCT city FROM 'zip_code' WHERE state_name='California' ORDER BY city ASC On the test server this query runs fine. So I upload the client site to my clients godaddy hosting, created the database, the stats are exactly the same PHP5.x and MySQL 4.1 But when I try to run that query on the database I get: #1064 - 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 ''zip_code' WHERE state_name = 'California' ORDER BY city ASC LIMIT 0, 30' at line 1 IM CONFUSED AS HELL?!?! WHy would this query work on my database running the same version, and not on their database which is on the same hosting and same version? I checked and the databases are identicle. Quote Link to comment https://forums.phpfreaks.com/topic/131832-query-works-on-one-server-not-the-other/ Share on other sites More sharing options...
veridicus Posted November 7, 2008 Share Posted November 7, 2008 Are the database settings identical on each server? The standard for mysql is to quote column and table names with backticks (`) and not single quotes. I think there's a setting to alter that. Try backticks or removing the quotes from the table name and you should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/131832-query-works-on-one-server-not-the-other/#findComment-684866 Share on other sites More sharing options...
advancedfuture Posted November 7, 2008 Author Share Posted November 7, 2008 yeah it was originally backticks, it didnt work so I changed it to single quotes with the same error Quote Link to comment https://forums.phpfreaks.com/topic/131832-query-works-on-one-server-not-the-other/#findComment-684900 Share on other sites More sharing options...
revraz Posted November 7, 2008 Share Posted November 7, 2008 You don't use single quotes around field names, remove them. Quote Link to comment https://forums.phpfreaks.com/topic/131832-query-works-on-one-server-not-the-other/#findComment-684905 Share on other sites More sharing options...
AndyB Posted November 7, 2008 Share Posted November 7, 2008 The standard for mysql is to quote column and table names with backticks (`) and not single quotes. No. The 'standard' is to avoid using MySQL reserved words for table or column names. And here they are - http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html Quote Link to comment https://forums.phpfreaks.com/topic/131832-query-works-on-one-server-not-the-other/#findComment-684929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.