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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.