Author Topic: Line 2052 MySQL error  (Read 3297 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: 13217
  • 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: 13217
  • 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: 13217
  • 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: 13217
  • 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: 13217
  • 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: 13217
  • 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 »

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Curse that error!
« Reply #15 on: April 19, 2008, 08:17:30 PM »
If you have more problems post back.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Curse that error!
« Reply #16 on: April 19, 2008, 08:22:11 PM »
Maybe just change the thread title to "Line 2052 MySQL error" or something like that, just in case someone else is wondering about the same thing. Up to you. I probably should have done it myself but I was feeling flippant.

Anyway it seems fine now. Cheers.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #17 on: April 19, 2008, 09:10:34 PM »
Changed...and glad it's fixed. :)

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #18 on: April 20, 2008, 06:07:59 PM »
Bother. Something I hadn't tested was the quick edit feature, and it looks like that is throwing up an error now. The old error is gone but attempting to use the quick edit now generates this:

Hacking attempt...

      SELECT IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.body, m.ID_TOPIC, m.subject, t.locked
      FROM (smf_messages AS m, smf_boards AS b, smf_topics AS t)
         LEFT JOIN smf_members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
      WHERE m.ID_MSG = 59527
         AND b.ID_BOARD = m.ID_BOARD
         AND t.ID_TOPIC = m.ID_TOPIC
         AND 1 ';
      LIMIT 1
File: /home/cofexm/public_html/Sources/Post.php
Line: 2052

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #19 on: April 20, 2008, 09:14:32 PM »
Do you have any mods installed that edit the post.php file. ??? If not try just replacing the whole thing.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #20 on: April 21, 2008, 04:00:02 AM »
They edit some parts of it but not that part. Rather than replacing it I can just undo the edit I did yesterday, but of course then I'll have the old error back. :grin

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #21 on: April 21, 2008, 11:08:38 AM »
Ok. can you re-upload your post.php again...the one you are using now.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #22 on: April 21, 2008, 04:21:40 PM »
Yep. Tis attached.  :)

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #23 on: April 21, 2008, 08:10:40 PM »
K; I will look at it now.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #24 on: April 21, 2008, 08:27:09 PM »
I think the ignore user mod is putting out the problems to tell you the truth.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #25 on: April 22, 2008, 03:43:32 AM »
I doubt it, because the MySQL syntax error has been around for months and Ignore User was only installed a couple of weeks back.

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #26 on: April 22, 2008, 07:28:01 AM »
Ok, well I will take another look when I get home today then. :)

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #27 on: April 25, 2008, 05:17:48 PM »
Any ideas? If not I'll have to return it to the original state since the current setup means the "Insert Quote" and "Quick edit" features don't work and both generate "Hacking attempt" errors.

Do those features use some other method to the rest of the forum code?

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #28 on: April 25, 2008, 10:35:39 PM »
Sorry I have not been able to look at this further; but might have time tomorrow night. I was at the home and garden show all day promoting my new business. I will try to take another look tomorrow though. If you would like until then I guess returning it to it's original state would be the best. I am sorry for the late response.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #29 on: April 25, 2008, 11:07:28 PM »
No worries. Ya gotta live and it isn't a humungous deal anyway. Was quite funny actually coz the other admin saw "Hacking attempt" in the error log and started squawking.  :dnc

It's a quick and easy edit so if nobody can figure a solution I'll just live with the old error. It'd be nice to clear it if possible though because as the forum grows it will start to accumulate quite a lot of errors.

Offline antechinus

  • Hero Member
  • *
  • Posts: 445
  • Karma: 65
Re: Line 2052 MySQL error
« Reply #30 on: April 27, 2008, 06:01:09 PM »
Ok I've decided not to worry about this and to just live with the original error. None of the gurus at SMF seem to know how to fix it either so it could be just one of those obscure gremlin things. It's manageable in terms of the number of errors and by the time it becomes unmanageable we'll be on SMF2, which will generate brand new errors. :dnc

Offline bigguy

  • Site Owner
  • Administrator
  • *
  • Posts: 13217
  • Karma: 269
  • Gender: Male
  • Get'r Done
    • P.C. Tweakr
  • SMF Version: 2.0 Gold
Re: Line 2052 MySQL error
« Reply #31 on: April 27, 2008, 08:12:28 PM »
I'll keep an eye open for a fix. ;)