Jump to content

[SOLVED] Sql Error


Stealth549

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.