[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 11-24-2007, 02:06 PM   #1 (permalink)
Senior Member
 
lpxxfaintxx's Avatar
 
Join Date: May 2006
Location: Irvine, CA
Posts: 1,060
261.85 NP$ (Donate)

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
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, 02:41 PM   #2 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (Donate)

-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of

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

$c->cat_ID is returning nada
-NC- is offline  
Old 11-24-2007, 02:44 PM   #3 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 03:27 PM   #4 (permalink)
Senior Member
 
lpxxfaintxx's Avatar
 
Join Date: May 2006
Location: Irvine, CA
Posts: 1,060
261.85 NP$ (Donate)

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, 08:05 PM   #5 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
What WP version are you using?
__________________
Eric is offline  
Old 11-24-2007, 08:14 PM   #6 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (Donate)

-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of

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 ";
}
-NC- is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:49 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85