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'"; Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/ 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'"; Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-356481 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'"; Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-356515 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 Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-356519 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 Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-356531 Share on other sites More sharing options...
fenway Posted September 27, 2007 Share Posted September 27, 2007 Echo the query. Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-356549 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' Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-357003 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? Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-357223 Share on other sites More sharing options...
Stealth549 Posted September 28, 2007 Author Share Posted September 28, 2007 ah, thanks. Link to comment https://forums.phpfreaks.com/topic/70901-solved-sql-error/#findComment-357241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.