-1

I'm getting an negative value error all the time from MySQL, when I run the query:

SELECT * FROM `nuke_multiheadlines_news` ORDER BY `news_status` ASC, `news_pubdate` DESC LIMIT -11800, -11795

index.php

I still get the same error and looks like there is something wrong but I can not find it.

  • You can't use `LIMIT` with negative numbers, what are you trying to do? – ekad Oct 02 '14 at 12:50
  • The module works properly but I am getting this stupid error all the time. How can I fix this issue? This module pulls the news from google, yahoo and severals links from the feed. – user2583893 Oct 02 '14 at 13:22
  • You need to identify how the module returns `-11800, -11795`. – ekad Oct 02 '14 at 13:31
  • Can you check if there is any mistake in the file to download. I'm working with this file from weeks and I got the same error. – user2583893 Oct 02 '14 at 13:35

1 Answers1

0

My guess would be that you run in to problems because you're using negative values in your LIMIT clause, from the documentation:

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).

Try changing the LIMIT clause to only use nonnegative numbers:

SELECT * FROM `nuke_multiheadlines_news` 
ORDER BY `news_status` ASC, `news_pubdate` DESC 
LIMIT 0, 5
Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
  • Yes I do know but where exactly. I have losts of DESC. Please specify! I posted the link to download. I need to know where. – user2583893 Oct 05 '14 at 15:36
  • @user2583893 - Read the documentation. You need to change the negative values in your `LIMIT` clause. – Cyclonecode Oct 05 '14 at 15:44
  • This is what I did and I am not getting any more error: $sql = 'SELECT * FROM `' . $prefix . '_multiheadlines_news`' . $string . ' AND `news_status` = 1 ORDER BY `news_pubdate` DESC LIMIT 0, 5';//LIMIT 0, 5 – user2583893 Oct 05 '14 at 15:53
  • The error came back. I am so dissapointed. Let me know what I must do. – user2583893 Oct 05 '14 at 16:30
  • I only get this :October 5, 2014, 6:54 pm File: /www.bestbuildpc.org/db/mysqli.php - Line: 201 Code: 1064 - Message: 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 '-11820, -11815' at line 1 SQL was: SELECT * FROM `nuke_multiheadlines_news` ORDER BY `news_status` ASC, `news_pubdate` DESC LIMIT -11820, -11815 remote addr: 66.249.65.132 – user2583893 Oct 05 '14 at 16:55
  • You will have to find out on which line number the query that is failing is located. Check out these posts for information about debugging your php scripts: http://stackoverflow.com/questions/888/how-do-you-debug-php-scripts and http://php.net/manual/en/debugger.php – Cyclonecode Oct 05 '14 at 17:19
  • I did lots of changes but unfortunately I get the error back again. it is frustrated!! Let me know if you have any solution about it. Code: 1064 - Message: 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 '-18450, -18445' at line 1 SQL was: SELECT * FROM `nuke_multiheadlines_news` ORDER BY `news_status` ASC, `news_pubdate` DESC LIMIT -18450, -18445 remote addr: 66.249.69.32 – user2583893 Oct 08 '14 at 11:34