Stealth549 Posted September 27, 2007 Share Posted September 27, 2007 Hey everyone, getting a sql error that I cannot pin down. 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 ' newspaper.id FROM subs , newspaper WHERE subs.news_id = newspaper.id AND newspa' at line 1 sql query $sql = "SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper.$day, newspaper.cost, newspaper.id FROM subs , newspaper WHERE subs.news_id = newspaper.id AND newspaper.$day = 'on'"; Quote Link to comment Share on other sites More sharing options...
jaymc Posted September 27, 2007 Share Posted September 27, 2007 Could it be the comma? $sql = "SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper.$day, newspaper.cost, newspaper.id FROM subs , newspaper WHERE subs.news_id = newspaper.id AND newspaper.$day = 'on'"; $sql = "SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper.$day, newspaper.cost, newspaper.id FROM subs, newspaper WHERE subs.news_id = newspaper.id AND newspaper.$day = 'on'"; If not, then try this $sql = "SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper.$day, newspaper.cost, newspaper.id FROM subs INNER JOIN newspaper ON subs.news_id = newspaper.id AND newspaper.$day = 'on'"; Quote Link to comment Share on other sites More sharing options...
Stealth549 Posted September 27, 2007 Author Share Posted September 27, 2007 there is still an error with all that. I have another query that is similar but works, all that is different is that i dont have newspaper.cost. $sql = "SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper.$day, newspaper.id FROM subs , newspaper WHERE subs.news_id = newspaper.id AND newspaper.$day = 'on'"; Quote Link to comment Share on other sites More sharing options...
jaymc Posted September 27, 2007 Share Posted September 27, 2007 Yeh, the error mysql has gave also shows it doesnt like the field newspaper.cost for what ever reason Are you sure it exists... what type of data is in there, what is the collation compared to your other ones Im not really sure on this one the query does look fine Quote Link to comment Share on other sites More sharing options...
Stealth549 Posted September 27, 2007 Author Share Posted September 27, 2007 I still get the error if I take that out, The field is varchar( and it stores numbers Quote Link to comment Share on other sites More sharing options...
fenway Posted September 27, 2007 Share Posted September 27, 2007 Echo the query. Quote Link to comment Share on other sites More sharing options...
Stealth549 Posted September 28, 2007 Author Share Posted September 28, 2007 Echo the query. SELECT subs.news_id, subs.cust_id, subs.sub_id, newspaper.name, newspaper., newspaper.id FROM subs , newspaper WHERE subs.news_id = newspaper.id AND newspaper. = 'on' Quote Link to comment Share on other sites More sharing options...
fenway Posted September 28, 2007 Share Posted September 28, 2007 "Newspaper." would be the error. $day is undefined? Quote Link to comment Share on other sites More sharing options...
Stealth549 Posted September 28, 2007 Author Share Posted September 28, 2007 ah, thanks. Quote Link to comment 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.