Topic: Form e-mail - Error: Unable to fetch topic info

I'm having a problem with the form e-mail in my forum. When I click on the link below the avatar for sending an e-mail to a user via the forum's form e-mail, I get the following error:

An error was encountered

Error: Unable to fetch topic info.

I've tried searching if someone has had the same problem before, but I came up empty (or didn't look in the right place). Since I don't know PHP, I have no idea where to even look. Would it help if I pasted code from a certain file? If so, please let me know from which file. My forum is located at www.chris-marquette.com/forum. I'm using version 1.2.17, but the last handful of versions were updated through manual Hdiff copying and pasting, so maybe something went wrong in the process. The upgrade was done a while ago, but I only just realized form e-mail isn't working today. I haven't made any other changes recently, and the rest of the forum seems to work fine.

I would be grateful if someone could help out. Thanks!

-TeeJay

Re: Form e-mail - Error: Unable to fetch topic info

Enable debug mode, paste the full error.

Re: Form e-mail - Error: Unable to fetch topic info

In debug mode, I get this error:

An error was encountered
File: /www/htdocs/w0072f62/forum/misc.php
Line: 83

PunBB reported: Unable to fetch topic info

Database reported: 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 'AND t.moved_to IS NULL' at line 1 (Errno: 1064)

Lines 82 to 85 in the misc.php file read as follows:

        // Make sure the user can view the topic
     $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id=1) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$topic_id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
     if (!$db->num_rows($result))
   message($lang_common['Bad request']);

Is this enough info to let me know how I can possibly fix it? Would be great if you could help. Thanks!

-TeeJay

Re: Form e-mail - Error: Unable to fetch topic info

Make sure $topic_id is set.

5 (edited by TJ_TeeJay 2008-04-24 19:31)

Re: Form e-mail - Error: Unable to fetch topic info

You're talking to someone who doesn't know anything about PHP programming. wink What does that mean?

-TeeJay

Re: Form e-mail - Error: Unable to fetch topic info

Okay, so I think you may mean this. In the same file (misc.php), lines 185 to 189 say this:

        // Get the topic ID
        $result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$post_id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        $topic_id = $db->result($result);

-TeeJay

Re: Form e-mail - Error: Unable to fetch topic info

That piece of code is about 150 lines too high if this is an unmodded install (and even if it isn't).

Re: Form e-mail - Error: Unable to fetch topic info

I replaced my old misc.php file with one from the latest clean version, and that seems to have solved the problem. Thanks for the help, guys. smile

-TeeJay