NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] MySQL Syntax Error!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-24-2007, 03:06 PM THREAD STARTER               #1 (permalink)
Senior Member
 
lpxxfaintxx's Avatar
Join Date: May 2006
Location: Irvine, CA
Posts: 1,082
lpxxfaintxx is just really nicelpxxfaintxx is just really nicelpxxfaintxx is just really nicelpxxfaintxx is just really nice
 



MySQL Syntax Error!


[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 wp_posts.ID = wp_term_relationships.object_id AND wp_term_relationships.' at line 7]

SELECT DISTINCT ID, post_title, post_date, wp_terms.term_id as post_category FROM wp_posts, wp_terms, wp_term_relationships, wp_term_taxonomy WHERE wp_terms.term_id = AND wp_posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id AND wp_term_taxonomy.term_id = wp_terms.term_id AND ID != 500 AND post_status = 'publish' ORDER BY post_date DESC LIMIT 400


This is the full query:


$category_check = " WHERE {$tp}terms.term_id = " . $c->cat_ID . " ";

$last_posts = (array)$wpdb->get_results("
SELECT DISTINCT ID,
post_title,
post_date,
{$tp}terms.term_id as post_category
FROM {$tp}posts, {$tp}terms, {$tp}term_relationships, {$tp}term_taxonomy
{$category_check}
AND {$tp}posts.ID = {$tp}term_relationships.object_id
AND {$tp}term_relationships.term_taxonomy_id = {$tp}term_taxonomy.term_taxonomy_id
????: NamePros.com http://www.namepros.com/programming/399425-resolved-mysql-syntax-error.html
AND {$tp}term_taxonomy.term_id = {$tp}terms.term_id
{$ddop_inc_current}
AND post_status = 'publish'
ORDER BY post_date {$newest_check}
LIMIT {$ddop_num}



Any idea what's wrong?
lpxxfaintxx is offline  
Old 11-24-2007, 03:41 PM   #2 (permalink)
Traveller
 
-NC-'s Avatar
Join Date: Mar 2007
Location: Yet another city
Posts: 1,419
-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future
 


Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
Quote:
wp_terms.term_id = AND
equals AND?

$c->cat_ID is returning nada
__________________
NameCooler.com
-NC- is offline  
Old 11-24-2007, 03:44 PM   #3 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Yes -NC- has pinpointed your problem. $c->cat_ID is not producing anything so wp_terms.term_id is not being compared to anything.
__________________
Manage your portfolio using my new Domain Portfolio Management script.
Securing Your Domain Name From Theft
Peter is offline  
Old 11-24-2007, 04:27 PM THREAD STARTER               #4 (permalink)
Senior Member
 
lpxxfaintxx's Avatar
Join Date: May 2006
Location: Irvine, CA
Posts: 1,082
lpxxfaintxx is just really nicelpxxfaintxx is just really nicelpxxfaintxx is just really nicelpxxfaintxx is just really nice
 



Ah! Any Wordpress/MySQL guru's want to help me get this figured out?
lpxxfaintxx is offline  
Old 11-24-2007, 09:05 PM   #5 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
What WP version are you using?
Eric is offline  
Old 11-24-2007, 09:14 PM   #6 (permalink)
Traveller
 
-NC-'s Avatar
Join Date: Mar 2007
Location: Yet another city
Posts: 1,419
-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future-NC- has a brilliant future
 


Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
rough hack off the top of my head:

if( is_numeric( $c->cat_ID ) ) {
$category_check = " WHERE {$tp}terms.term_id = " . $c->cat_ID . " ";
}else{
$category_check = " WHERE 1=1 ";
}
__________________
NameCooler.com
-NC- is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:27 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger