Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

SSI Single Message Mod problems

Aloittaja sonicslp, kesäkuu 10, 2008, 03:58:41 AP

« edellinen - seuraava »

sonicslp

I'm having trouble with the SSI Single Message mod.

All quotes/apostrophes are coming out as question marks and I can't figure out where/how to fix it. Are the forum posts not being inserted properly into MySQL by SMF? Does it not use addslashes?

MySQL 4.23
PHP 4.3.11
SMF 1.1.4

IchBin™

What is your forum language set to, and what is your database language set to?

Make sure if you are using a UTF8 language, that you have the utf8 language files in your default theme. I'm not sure how the languages work much, but you should probably make sure your database is saving as UTF8 if youre using UTF8 as well.
IchBin™        TinyPortal

IchBin™

Another question, are you seeing this only through the grabMessage function? Or do you see it in other places on your board?
IchBin™        TinyPortal

sonicslp

Only the grabMessage function, the board displays the messages correctly. I'll check out the UTF8 stuff and get back to you.

sonicslp

#4
The MySQL db is set to Collation utf8_general_ci but if I go into the SMF tables I see that a lot of them are either unset or say "latin1_swedish_ci"

I'm just using English for the forum, have no idea what SMF does outside of that.

IchBin™

Going to see if I can get some input from someone that knows language/character issues.
IchBin™        TinyPortal

Sarge

Lainaus käyttäjältä: sonicslp - kesäkuu 10, 2008, 03:58:41 AP
MySQL 4.23

I don't recognize this MySQL version... Can you copy/paste it from SMF Admin > Support and Credits > Version Information section?

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Lainaa
<H> I had zero posts when I started posting

sonicslp

Sorry about that, brain fart on my part. The MySQL version is actually 3.23.49 according to phpinfo(). Oddly, if I look at "Support and Credits" in SMF it says "MySQL version: 4.1.7-nt"

sonicslp

I'm still stumped on this one. Any updates?

Sarge

I assume you are displaying single messages on the homepage, or some other page outside SMF?

What are the selected page encodings (View menu > Character Encoding in Firefox, View > Encoding in IE) for SMF and the page where single messages are displayed?

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Lainaa
<H> I had zero posts when I started posting

sonicslp


Sarge


    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Lainaa
<H> I had zero posts when I started posting

sonicslp

#12
Ah! I assumed both were UTF-8 but the forum is Western. That's what I get for assuming. Thanks a bunch man!

One other quick question...

Can I set your mod to only display a certain length of the post and have a link to the full forum post?

IchBin™

You can limit the output of the body by changing a couple of things.

First add $func to the global list at the beginning of the function in SSI.php. Second, change this line:
'body' => $row['body'],

To this:
'body' => $func['substr']($row['body'], 0, 120),

120 being the amount of characters you want it to have.

To change the link to the post to link to the topic, change this line:
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">'.$txt['gsm_read_more'].'</a>',

To this:
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">'.$txt['gsm_read_more'].'</a>',
IchBin™        TinyPortal

sonicslp

Thanks a bunch for the help, it's working perfect!

kai920

hey IchBin - how do I modify this code to fetch the first attachment of the single message?

I used this code successfully with ssi_boardNews() but would appreciate some help with the SQL:


// Find their attachments.
       $request = db_query("
          SELECT ID_ATTACH, ID_THUMB, ID_MSG, filename, size, downloads
          FROM {$db_prefix}attachments
          WHERE ID_MSG IN (" . implode(', ', $message_ids) . ")", __FILE__, __LINE__);
       while ($row = mysql_fetch_assoc($request))
       {
          $return[$row['ID_MSG']]['attachments'][] = array(
             'name' => $row['filename'],
             'downloads' => $row['downloads'],
             'size' => round($row['size'] / 1024, 2) . ' ' . $txt['smf211'],
             'byte_size' => $row['size'],
             'thumb' => ($row['ID_THUMB']==0 ? ($scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH']) : ($scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_THUMB'])),
             'href' => $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'],
             'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $return[$row['ID_MSG']]['id'] . '.0;id=' . $row['ID_ATTACH'] . '">' . $row['filename'] . '</a>'
          );
       }
   mysql_free_result($request);
      return $return;

kai920

#16
I think I got the SQL statement correct, but when I try to return the attachment array it somehow overwrites the earlier result in green?  I get an Undefined index:  body error as long as the statement in red exists.

Any help please?

Lainaa
        $return[] = array(
        'body' => $row['body']
        );

Lainaa
// Find their attachments.
       $request = db_query("
          SELECT ID_ATTACH, ID_THUMB, ID_MSG, filename, size, downloads
          FROM {$db_prefix}attachments
          WHERE ID_MSG = (" . ($message_id) . ")", __FILE__, __LINE__);
        $row = mysql_fetch_assoc($request);
        $return['attachment'][] = array(
                'name' => $row['filename']
            );

    mysql_free_result($request);
      return $return;

Advertisement: