Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can someone help me find the error in this query? 1

Status
Not open for further replies.

JohnnyT

Programmer
Jul 18, 2001
167
GB
Hi all,
I'm by no means an expert in SQL and have a query that's causing an error in my logs. The error is:
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 'AND user_gifts.status = 1 AND gifts.ID != 26 AND gifts.ID != 114 AND gifts.ID !=' at line 1 for query SET NAMES 'utf8' made by require, require_once, include, get_user_gifts

The query I think it refers to is:
$q = 'SELECT *, (SELECT COUNT(*) FROM '.$wpdb->prefix.'user_gifts u_gifts WHERE u_gifts.gift_ID = user_gifts.gift_ID) as `count` FROM '.$wpdb->prefix.'user_gifts user_gifts INNER JOIN '.$wpdb->prefix.'gifts gifts ON gifts.ID = user_gifts.gift_ID WHERE user_gifts.user_ID = '.$user_ID.' AND user_gifts.status = 1 AND gifts.ID != '.$candle_db_id.' AND gifts.ID != '.$music_db_id.' AND gifts.ID != '.$user_defined_memorial_image.' '.( $group_by ? 'GROUP BY '.$group_by : '' ).'';

Has anyone any idea what is wrong with this query??

Thanks for any light you can shed on this.

;-)

Spend a few minutes remembering your loved ones,
Create a permanent memorial to commemorate their life,

 
Thanks for your advice. I've managed to work out what the problem was and you were right. There was occasions when user_ID wasn't set.

Thanks again

;-)

Spend a few minutes remembering your loved ones,
Create a permanent memorial to commemorate their life,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top