Shoutbox

What's wrong with this SQL? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: What's wrong with this SQL? (/showthread.php?tid=80673)

What's wrong with this SQL? by Baggins on 01-04-2008 at 03:47 AM

I am trying to find the url of the latest 'published' wordpress 'post':

code:
SELECT guid FROM wp_posts WHERE post_status='publish' AND post_type='post' ORDER BY post_date_gmt DESC LIMIT 1
It returns this error
quote:
Originally posted by mySQL

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/****/*******/******/************.php on line 666
Could mean empty result set?
I removed 'LIMIT 1' and it returned a list of post url's sorted just how I want.
I also tried:
code:
SELECT guid FROM wp_posts WHERE post_status='publish' AND post_type='post' ORDER BY post_date_gmt DESC LIMIT 0,1
No luck! :sad:
Rep
UPDATE: I just read john-t's thread and it seems we are having the same problem, something to do with LIMIT.
RE: What's wrong with this SQL? by MeEtc on 01-04-2008 at 04:01 AM

Query looks fine to me, I even ran it in PMA and had a result returned. The only way I can see this failing, is if you don't have any posts made yet on WP


RE: What's wrong with this SQL? by Baggins on 01-04-2008 at 04:02 AM

Hmmmm, my database is full. However I am using WizMySQLAdmin (pma is kinda slow), so I will try PMA.

EDIT: Works in PMA, thanks MeEtc!