vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Displaying Posts from a Thread (https://vborg.vbsupport.ru/showthread.php?t=315132)

Nothematic 10-29-2014 09:43 PM

Displaying Posts from a Thread
 
Hi all,

I'm trying to display every post in a specified thread on an external page. I'm using this (awful) code but I'm not able to get it to display anything. Anyone got any ideas as to why? I'm not the best when it comes to PHP and MySQL. Thanks.

Code:

<?php
                $username = *FORUM_DB_USERNAME*
                $password = *FORUM_DB_PASSWORD*
                $forumcon = new PDO('mysql:host=localhost;dbname=*FORUM_DB_NAME*', $username, $password);
               
                $posts = "SELECT `title`, `pagetext` FROM `post` WHERE `threadid=2"; //specified threadid 2
                $result = $forumcon->prepare($posts);
                $result->execute();
               
                while($row = $result-fetch()) {
                        echo "<b>" . htmlspecialchars($row['title']) . "</b>";
                        echo "<hr />";
                        echo htmlspecialchars($row['pagetext']);
                        echo "<br /><br />";
                }
        ?>


kh99 10-30-2014 08:29 AM

I'm not familiar with PDO so I don't know if the code is correct, but in the sql string you have a backtick at the beginning of threadid, but not at the end.


All times are GMT. The time now is 01:13 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.01323 seconds
  • Memory Usage 1,709KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete