CodingHelp with MySQL (i think) problem?

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Jo (JELLS)  
 To:  ALL
31182.1 
About 3 weeks ago, I moved my website, which hosts my blog, to new hosting. Since then, one of the blog feed aggregators I belong to, Progressive Bloggers, won't pick up my blog feed. It works fine with the other two aggregators I belong to, however.

I have had the mods at Progressive Bloggers look into this and this is the latest report:

quote:
I'm helping Scott troubleshoot the ProgBlog feed problem. I think it's related to your feed, and not our site. It comes up with the following error for your feed in Internet Explorer, even though it works in Firefox.

WordPress database 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 '' at line 1]
SELECT DISTINCT * FROM election_posts WHERE 1=1 AND post_date_gmt <='2006-11-13 03:47:59' AND (post_status = "publish") AND post_status !="attachment" GROUP BY election_posts.ID ORDER BY post_date DESC LIMIT 0,

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0201/d11/s43/b028b69a/www/canadian-politics.com/vues/wp-includes/wp-db.php:102)
in /mnt/w0201/d11/s43/b028b69a/www/canadian-politics.com/vues/wp-rss2.php on line 8
http://canadian-politics.com/vues Fri, 10 Nov 2006 21:04:33 +0000
http://wordpress.org/?v=2.0.2


I have no idea what this means. I also don't understand why it still works fine with the other two aggregators, but not Progressive Bloggers. I've posted on the WordPress support forum asking about this, but no replies thus far. Does anyone here have any ideas?
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.2 In reply to 31182.1 

Looks like it's because the query has double quotes instead of single quotes round the post_status values in the WHERE statement. I'm not a MySQL expert, but if it's anything like MSSQL, those should be single quotes.

 

It looks like it's a Wordpress bug. What version are you using? I'm guessing from the "vues" folder that it's the French (or French Canadian) version.


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Kenny J (WINGNUTKJ)     
31182.3 In reply to 31182.2 

(except that I'm talking nonsense about the vues folder)


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  Jo (JELLS)     
31182.4 In reply to 31182.1 
What Kenny said - it's very probably a WordPress bug, and related to the double quotes.

You could go in yourself and try changing the double quotes to single, but that alone might not fix the problem, and it's probably safer to politely shout at the WordPress people until they respond. :)
0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Kenny J (WINGNUTKJ)     
31182.5 In reply to 31182.2 
It's english - i only gave my blog a french name to be clever-like. I'm still using version 2.0.2 (they're up to 2.0.5 - but that's what i was using before i changed hosting and moved the database, and it worked fine with that aggregator before the move). I could try upgrading to 2.0.5 i suppose.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Peter (BOUGHTONP)     
31182.6 In reply to 31182.4 
hehe... Well, no one's replied to my post over there yet.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.7 In reply to 31182.5 

I realised that once I'd posted, and I'm on lite mode just now, so couldn't be bothered faffing around to edit.

 

I'll have a look at my own Wordpress site tonight to see what the code's like.


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Kenny J (WINGNUTKJ)     
31182.8 In reply to 31182.7 
Ta - i'd appreciate that.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Jo (JELLS)     
31182.9 In reply to 31182.1 

The syntax for LIMIT on the end of the query is incorrect. It should contain a second number after the comma, i.e. LIMIT 0, 10.

 

One of the WordPress PHP scripts is probably supposed to check for a variable in the URL query which tells the script how many entries form your blog it is supposed to output into the RSS feed. If this script isn't checking the variable correctly and an empty string (or worse any data) is being allowed to be used to form part of the LIMIT clause then that could cause the error you've described.

 

To fix it you could try and upgrade WordPress to see if it is a known bug that has been squashed in a newer version. Failing that it's probably best to tell them about it ASAP in case the bug can be used to perform an SQL injection attack.

doohicky

0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Matt     
31182.10 In reply to 31182.9 

Thanks. I'll give updating a try...

 

But why then does the feed work for everyone else except this one aggregator? I have a feed for the blog set up with LiveJournal, and it still works (as in new posts show up), two other blog aggregators still show my new posts as i make them, and if someone subscribes to my blog's feed, it works there too (at least, it does for me - and yes, i subscribe to my own blog's feed).

 

And as i said, this was working fine up until i moved the blog database to the new hosting a few weeks ago. So i'm not certain it's a WP issue and maybe something that went screwy with the database import? Altho wouldn't that bugger it up for all feeds from my blog?

0/0
 Reply   Quote More 

 From:  Matt  
 To:  Jo (JELLS)     
31182.11 In reply to 31182.10 

I don't know.

 

If I had to guess, I would say the feed aggregator that has the problem could quite possibly be trying to limit the number of entries it is sent and because of this [possible] bug in WordPress the RSS feed isn't correctly generated and it falls over.

 

Meanwhile the aggregators that do work are not limiting the number of entries they fetch which means the bug doesn't come into play for them.

 

Or it could be the other way around and WordPress is expecting a URL Query variable to tell it how many entries to fetch and the troublesome aggregator isn't providing it.

doohicky

0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Matt     
31182.12 In reply to 31182.11 

Well, i'll start by upgrading to 2.0.5 and see what that solves, if anything.

 

Thanks again!

0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.13 In reply to 31182.1 
The offending function is get_posts() in the wp-includes folder. Like Matt, says, the LIMIT bit at the end should have a valid value. In my version, the code is:

PHP code:
 
function get_posts($args) {
	global $wpdb;
	parse_str($args, $r);
	if ( !isset($r['numberposts']) )
		$r['numberposts'] = 5;
	if ( !isset($r['offset']) )
		$r['offset'] = 0;
	if ( !isset($r['category']) )
		$r['category'] = '';
	if ( !isset($r['orderby']) )
		$r['orderby'] = 'post_date';
	if ( !isset($r['order']) )
		$r['order'] = 'DESC';
 
	$now = current_time('mysql');
 
	$posts = $wpdb->get_results(
		"SELECT DISTINCT * FROM $wpdb->posts " .
		( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
		" WHERE post_date <= '$now' AND (post_status = 'publish') ".
		( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
		" GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
 
	update_post_caches($posts);
 
	return $posts;
}
 


That suggests to me that if it can't find a value, it'll default to 5.

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Kenny J (WINGNUTKJ)     
31182.14 In reply to 31182.13 
quote:
The offending function is get_posts() in the wp-includes folder


Is that the name of the file? I'm looking at the contents of my wp-includes folder and i don't know what file i should be looking for...

ETA: Right, found the file in question and it says exactly what yours does.

I'll try upgrading to 2.0.5 - probably not tonight, however. I hate messing with databases and just don't feel like attempting that right now.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.15 In reply to 31182.14 

Sorry about that; my mind was kind of mush last night. It's in functions.php, as you've found.

 

I'm not a PHP expert, but I'm wondering if there's some condition where the variable is set to null, or an empty string or something, so it passes the isset() test, but doesn't show up in the string.

 

What say the PHP experts?


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Kenny J (WINGNUTKJ)     
31182.16 In reply to 31182.15 

Without seeing how the function arguments are handled it's hard to say for sure.

 

But, if that is the only test they're performing on the data then they need to add more. At the moment a variable could be an empty string and it would pass their basic checks.

doohicky

0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Matt     
31182.17 In reply to 31182.16 
I'll have a look deeper into it tonight and try to trace the flow of it. If it was in the querystring as ?var=&someothervar=2 or something, would that pass the isset test?

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)  
 To:  Kenny J (WINGNUTKJ)     
31182.18 In reply to 31182.17 
Out of curiosity, which version of WordPress are you using? 2.0.5?
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.19 In reply to 31182.18 
I'm on 2.0.4 just now. I've not got round to updating to the new one yet.

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)     
31182.20 In reply to 31182.18 
Oh and:

quote: Them
What’s new? We have about 50 or so bugfixes, which you can review on our dev tracker here, mostly minor bug fixes around feeds, custom fields, and internationalization.


Could be what you're after...

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

Reply to All  
 

1–20  21–22

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats