vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Speech-mark turns to " in result of a query (https://vborg.vbsupport.ru/showthread.php?t=189716)

sparklywater 09-01-2008 10:01 AM

Speech-mark turns to " in result of a query
 
I have this function which trims the thread-title of the latest posts after a query fetches the latest posts. Everything works well except I've noticed that if this query trims the thread-title at a speech-mark ( " ) , instead of displaying the speech-mark in the result it shows &quo... instead. But if I increase the cut-off by a few more characters then the speech mark is displayed correctly. How can I make the query display the speech-mark without it displaying '&quot...' at certain lengths of cutoff?

Here is the query to trim the thread-title:

PHP Code:

if (strlen($row['thread_title']) > $vbulletin->options['latest_trimplusthree'])
       {
        
// adds the cutoff ... with substr
        
$row['thread_title'] = substr($row['thread_title'], 0$vbulletin->options['latest_trim']) . '...';
       } 

--------------- Added [DATE]1220329262[/DATE] at [TIME]1220329262[/TIME] ---------------

someone help please...

sparklywater 09-03-2008 12:27 AM

has this been posted in the right section?

Marco van Herwaarden 09-03-2008 09:40 AM

Try using multibyte functions instead. So mb_substr() instead of substr(), and mb_strlen() instead of strlen().

sparklywater 09-03-2008 10:17 AM

Thanks for your reply, I've just tried that but it still shows &quo... in the results.

--------------- Added [DATE]1220440916[/DATE] at [TIME]1220440916[/TIME] ---------------

This is the query which fetches the latest posts:

PHP Code:

// query to get the last posts
    
$query $vbulletin->db->query_read_slave("
        SELECT
            post.postid, post.pagetext as pagetext, post.userid, post.username, post.dateline AS date,
            thread.forumid, thread.title as thread_title, thread.threadid,
            forum.forumid, forum.title as forum_title, thread.replycount as replies, thread.views as views
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "post AS post on (post.postid = thread.lastpostid)
        INNER JOIN " 
TABLE_PREFIX "forum AS forum on (thread.forumid = forum.forumid)
        WHERE post.visible = '1' AND thread.visible = '1' AND open = '1' AND 
$platest_and AND $platest_and_1
        ORDER BY postid DESC
        LIMIT 
$plimit"
    
); 


Opserty 09-03-2008 10:50 AM

Try the fetch_trimmed_title vBulletin function instead.

sparklywater 09-03-2008 01:03 PM

Quote:

Originally Posted by Opserty (Post 1613494)
Try the fetch_trimmed_title vBulletin function instead.

Thanks but I have no idea how to use that function.

Opserty 09-03-2008 01:27 PM

Did you click the link and read the function description? ;)

sparklywater 09-03-2008 04:56 PM

Quote:

Originally Posted by Opserty (Post 1613576)
Did you click the link and read the function description? ;)

How can I make that function work with this query:

PHP Code:

// query to get the last posts
    
$query $vbulletin->db->query_read_slave("
        SELECT
            post.postid, post.pagetext as pagetext, post.userid, post.username, post.dateline AS date,
            thread.forumid, thread.title as thread_title, thread.threadid,
            forum.forumid, forum.title as forum_title, thread.replycount as replies, thread.views as views
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "post AS post on (post.postid = thread.lastpostid)
        INNER JOIN " 
TABLE_PREFIX "forum AS forum on (thread.forumid = forum.forumid)
        WHERE post.visible = '1' AND thread.visible = '1' AND open = '1' AND 
$platest_and AND $platest_and_1
        ORDER BY postid DESC
        LIMIT 
$plimit"
    
); 


Opserty 09-03-2008 06:27 PM

You don't use it in the query... you do it to the title you've fetched.

sparklywater 09-03-2008 06:57 PM

The query has the following line which fetches the thread title, doesn't it?

PHP Code:

 SELECT
          thread
.title as thread_title 


I have to use that query to get the latest posts on the forum, but the part I'm stuck on is using a function to correctly trim the thread-title of these latest posts.

If I use the function you linked to, I would have to make it work with this query which fetches the actual posts, is that not correct? The title itself isn't enough because I need the thread-titles to link to the latest posts.


All times are GMT. The time now is 04:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01355 seconds
  • Memory Usage 1,756KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete