Jump to content

[SOLVED] SMF problem with limit


rockinaway

Recommended Posts

	$articles = db_query("
		SELECT date, author, subject, body, id
		FROM {$db_prefix}tp_articles 
		ORDER BY date DESC LIMIT 0,2", __FILE__,__LINE__);

 

That is my code, I want the latest article but when I have the LIMIT set to 0,1 then no article is shown, even though there is a newer article.. what could be the problem?

Link to comment
Share on other sites

You can just use "limit 1" also "date" is a reserved word in MySQL so you should change the column name to something more meaningful or enclose the column name in backtick marks (i.e. `date`).

 

Try the query outside of php code first (like using sqlyog or phpmyadmin). When it works there, put it into the code. As part of debugging this, display the full query to make sure it's what you expect.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.