TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,217
  • Total Topics: 21,351
  • Online today: 556
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 324
  • Total: 324

PHP Articles empty [SOLVED]

Started by Jaga, January 09, 2009, 03:29:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jaga

Link to my site: http://www.psimod.com/index.php
SMF version: 1.1.7
TP version: 0.98
Theme name and version: DarkBreak by DzinerStudio
Mods installed:
  • TinyPortal     0.983
  • Aeva ~ Auto-Embed Video & Audio    5.0 b1
  • Sarcasmics smiley set    1.1.0.1
  • Member Color Link    3.0.5a
  • GeSHiSmf    0.1.4
  • Karma Buttons    1.1
  • No Single Character Serach    1.0.5
  • Prettier_Quotes    1.12
  • Cilickable posts    0.1
  • Bakers Dozen Pages    1.1
  • Spiders Don't Increase Topic Views    1.1
  • Member List Position Filter    1.1.0
Related Error messages: n/a

Simply put - no matter what sort of content I enter into a new PHP Article, it previews/displays blank.  I've even tried something as simple as:

<?php
 phpinfo
();
 
// prints e.g. 'Current PHP version: 4.1.1'
 
echo 'PHP version: ' . phpversion();
?>


My intent was to embed the php for a piece of chat software directly into an article and have it display, but it appears there are other issues I need to resolve first.  Standard HTML style articles display content entered into them.

Jaga

Update:  By removing the <?php and ?> tags I am able to get the PHP articles parsed, but due to being inside those tags natively, I still can't get the output to happen with my original code.  It uses the following inside HTML tags to print the output to the page:

<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>

<body>
<div class="content">
  <?php $chat->printChat(); ?>
</div>

</body>
</html>


Looks like I'm back to square one!

Ken.

Hi Jaga, welcome to TinyPortal.

One of our code specialists will need to check your actual code to see if it's OK, but for starters I can tell you that the php tags are not required in your article, so you need to remove them.
<?php  ?>
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

Jaga

Thanks for the reply Ken - you'll note I figured that out and posted just before you did.  Now I need to find a way to produce the output to what used to be the HTML section, from within a PHP block.  As I'm not a PHP expert, that may or may not happen.

And trying to use a HTML article with the original code (both PHP and HTML blocks) fails miserably - it truncates large portions and doesn't seem to parse any of it.

I'll keep playing with it, unless someone can point out an easy solution.

JPDeni

Mixing html and php is a whole different ball of wax, which is something we don't usually do in php articles. There's no reason at all to have all of the page stuff in an article, because that is already printed out by TP. So, without the html, all you're left with is


<div class="content">
  <?php $chat->printChat(); ?>
</div>


which won't work either, but at least we've narrowed things down a bit. :)

Just looking at the structure of the code and not the content of it, the best way to print it out in a php article would be


echo '<div class="content">';
$chat->printChat();
echo '</div>';


That will give you the correct structure, but it likely *still* won't work because you have a call to a function that doesn't exist in either SMF or TP. Without knowing what the function printChat() is and where it is, there's no way to help with debugging it.

Jaga

Thanks for the info JPDeni.  I finally realized I was spending too much time futzing with it, and not enough getting actual work done.  The final solution, while not elegant or integrated, works - an IFrame.

What would be more beneficial (to probably everyone running TP), is not automatically wrapping the content with the PHP tags.  That would require the user place the tags in, though TP would still parse the block for PHP and other elements.  That way it might work with the HTML near the bottom, and mixing/matching would be possible..

Just a suggestion, as I said I'm not the expert.  Cheers.

JPDeni

Quote
What would be more beneficial (to probably everyone running TP), is not automatically wrapping the content with the PHP tags.

Well, the way it works is that the code is placed in an eval function in order for the php to be run. This is just the nature of the function and not anything that is unique to TP.

You can use html with php articles in TP. It's just that it's not usually done and it wasn't necessary in this case.

This website is proudly hosted on Crocweb Cloud Website Hosting.