Author Topic: Line 2052 MySQL error  (Read 3293 times)

0 Members and 1 Guest are viewing this topic.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Line 2052 MySQL error
« on: April 19, 2008, 05:47:42 PM »
Allll righty then, I got me one little error that keeps popping up. I've finally managed to get rid of all the others so this one is going too.

The message is:

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 ')      LIMIT 1' at line 8 File: /home/cofexm/public_html/Sources/Post.phpLine: 2052

and the code for Line 2052 of Post.php is:

:
LIMIT 1", __FILE__, __LINE__);
Any tips on what the code should be? Do I just ditch one of the apostrophes or what?
« Last Edit: April 19, 2008, 09:10:07 PM by bigguy »

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #1 on: April 19, 2008, 05:56:03 PM »
This is a complete guess and I don't know why I would think this but maybe this:

:
LIMIT 1"
should be this:

:
LIMIT 1'
Also that probably won't work so back up first if you do try it. What mods do you have installed. ???

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #2 on: April 19, 2008, 05:58:42 PM »
Mods are Tiny Portal 0.983, Ignore  User and vReportBoard. 

I don't think any of those touch that line of code, but I may be wrong about TP.
 

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #3 on: April 19, 2008, 05:59:31 PM »
I'll give it a shot on my test forum.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #4 on: April 19, 2008, 06:04:00 PM »
Hey the funny thing is that 12 other lines (ranging from 136 to 2287) have the same syntax.
ie: LIMIT 1", __FILE__, __LINE__);

I don't get error messages for these other code lines. It's only 2052. ???


ETA: Hey, your modify button is working today. Kewl.  :dnc

Anyway, I dug up the search results for LIMIT from the MySQL 4.1 manual but I don't know what sort of command the one in Line 2052 of my Post.php file is.

About half the search results are for common uses of the word "limit" so they're obviously not applicable, but I still don't know which one(s) out of the results for LIMIT I should be looking at.
 
« Last Edit: April 19, 2008, 06:27:54 PM by antechinus »

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #5 on: April 19, 2008, 06:36:26 PM »
Can you post at least 5 lines above and below that one you are getting errors from. Sometimes it's not always THAT particular line but one around it that is causing the error.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #6 on: April 19, 2008, 06:46:16 PM »
Sure. Here's the relevant block of code.

:
$request = db_query("
        SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject, t.locked
        FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
            LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
        WHERE m.ID_MSG = " . (int) $_REQUEST['quote'] . "
            AND b.ID_BOARD = m.ID_BOARD
            AND t.ID_TOPIC = m.ID_TOPIC
            AND $user_info[query_see_board]" . (!isset($_REQUEST['modify']) || (!empty($moderate_boards) && $moderate_boards[0] == 0) ? '' : '
             AND (t.locked = 0' . (empty($moderate_boards) ? '' : ' OR b.ID_BOARD IN (' . implode(', ', $moderate_boards)) . ')' . ')') . "
        LIMIT 1", __FILE__, __LINE__);
    $context['close_window'] = mysql_num_rows($request) == 0;

    $context['sub_template'] = 'quotefast';
    if (mysql_num_rows($request) != 0)
    {
        $row = mysql_fetch_assoc($request);
        mysql_free_result($request);

That runs from 2043 to 2059 inclusive.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #7 on: April 19, 2008, 06:51:30 PM »
I'm thinking it's at the end of this line:

:
             AND (t.locked = 0' . (empty($moderate_boards) ? '' : ' OR b.ID_BOARD IN (' . implode(', ', $moderate_boards)) . ')' . ')')
Because of what this part of the error message says:

MySQL server version for the right syntax to use near ')


Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #8 on: April 19, 2008, 06:55:13 PM »
K. That looks plausible, because there's some excess closing brackets on that line, if I'm not mistaken.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #9 on: April 19, 2008, 06:59:05 PM »
At the end try something like this:

:
(' . implode(', ', $moderate_boards)) . ')' . ')')';
Or this:

:
(' . implode(', ', $moderate_boards)) . ')' . ')')'
Or this:

:
(' . implode(', ', $moderate_boards)) . ')' . ')');
Those are the only guesses I have right now. If you want to upload the file I will see what debugging it does. :)

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #10 on: April 19, 2008, 07:04:41 PM »
Righty-o. Here's the file then. It's running with MySQL 4.1.22

I had another look and I have a hunch (warning: n00b at work!) that this bit:

:
. ')' . ')') . "
could be the problem. I'm wondering if the extra apostrophe in    ' ) '  is the problem, since the error message said syntax to use near ' )

The other brackets on that line just have preceding apostrophes and no following one. If the following one is an invalid syntax that would give the message.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #11 on: April 19, 2008, 07:40:44 PM »
Have you made your suspected changes. ??? Try out what you think. I will take a look at this now and debug it.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #12 on: April 19, 2008, 07:42:34 PM »
Yeah I just tried it. I removed that apostrophe and got myself a nasty parse error.  :grin

So much for my hunch.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13215
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #13 on: April 19, 2008, 07:47:58 PM »
At the end of line 2051 add:

:
';
And see what happens.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #14 on: April 19, 2008, 08:00:25 PM »
That might have done it. I loaded that version, created a new test topic, then locked and unlocked and moved the thread to another sub-forum. I figure since this code block is to do with moderation functions a few basic moderation tests were a good idea.

There's no parse errors coming up and nothing in the admin centre error log. I think this version is safe to run on the public forum, at least until  something shows up in the log.

ETA: Since it seems to work I'll tick this off as solved for now and keep an eye on how it runs. If there's any more dramas I'll post here, but I think it's ok. Thanks for your help.

ETA2: You'll have to do the tick thing for the OP. Modify button is only showing on the last couple of posts for me.
« Last Edit: April 19, 2008, 08:06:46 PM by antechinus »