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,970
  • Latest: bynw
Stats
  • Total Posts: 196,047
  • Total Topics: 21,336
  • Online today: 163
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 129
  • Total: 129

need help getting a php block to work

Started by srm, April 21, 2008, 06:12:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

srm

I created a block and put the php file inside the same directory where SMF root is

here is the file i created with a table nested in it.


http://sputnikradio.com/chat/index2.php


I am trying to get that table to nest inside a block or an article ..I have tried using add php in articles and making php blocks...I evven tried it as an html block . it gives errors and stuff about sources/load.php line 1 and stuff.


I hacked the code to get the little table for my chat login to work outside the chat directory and as you can see its working just fine however it dont work when i put it in a block or article..even though i have a test file working in the smf root directory here http://sputnikradio.com/chat/index2.php

any help please

JPDeni

It's pretty hard to debug code when I can't either see the code nor have exact error messages. I have a guess that you have started your code with


<?php


and ended it with


?>


If that is true, then remove those codes from your block and it should work unless you have other errors.

If you want any further help with debugging, you'll need to post the code -- with the code tags as I have done (you can use the # button on the posting form) -- and the complete error messages.

srm

thanks for the reply. I took out those tags like you said and am still getting an error....

Here is more info :


//THIS IS THE CODE

<table width="160" border="0" bgcolor="#000000">
  <tr>
    <td><?php   
   error_reporting( E_ALL ^ E_NOTICE );
   
   require_once('../chat/inc/smartyinit.php');
   
   //check for install--------------------------------------------------------------------------
   $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}connections LIMIT 1");
   $res  = $stmt->process();
   if($res == null)
   {
      Header("Location: ../chat/install.php"); 
      die;
   }
   //-------------------------------------------------------------------------------------------
   $data = array();
   
   $data['version'] = $GLOBALS['fc_config']['version'];
   $data['file_exists'] = file_exists('../chat/install.php') || file_exists('../chat/install_files');
   
   ChatServer::loadCMSclass();
   $cms = $GLOBALS['fc_config']['cms'];
   $cmsclass = strtolower(get_class($cms));
   $data['is_cms'] = ($cmsclass == 'defaultcms') && (! isset($cms->constArr) );
   
   $data['languages'] = $GLOBALS['fc_config']['languages'];
   $data['defaultLanguage'] = $GLOBALS['fc_config']['defaultLanguage'];
   
   $data['is_statelesscms'] = ($cmsclass == 'statelesscms');
   $data['adminPassword']   = $GLOBALS['fc_config']['adminPassword'];
   $data['moderatorPassword'] = $GLOBALS['fc_config']['moderatorPassword'];
   $data['spyPassword']     = $GLOBALS['fc_config']['spyPassword'];
   
   $smarty->assign('data', $data);
   $smarty->display('index3.tpl');
?>
      &nbsp;</td>
  </tr>
</table>


//END OF CODE



//This is the ERROR MESSAGE I AM GETTING

Parse error: syntax error, unexpected '<' in /home/sputnikr/public_html/main/Sources/Load.php(1735) : eval()'d code(209) : eval()'d code on line 1



//END ERROR MESSAGE

srm

Never mind I fixed it...i had to take it out of the table i had put it in

anyway to put it in a table? then a block or article?

JPDeni

What you have in your code is not php. It's html. (It's very difficult to read your code because you didn't use the code tags as I asked you to.)

I always find it confusing to mix php and html, but I think you can use your code if you start it with


?>


and end it with


<?php


This is exactly the opposite of what you probably had to start with and what I told you to get rid of. It's all because the contents of a php block or a php article is executed by the use of an "eval" function.

Personally, I think it's better to write the whole thing in php, but that may just be me. :)

srm

yeah im not that great of an originiator of codes I pretty good at hacking it up and trying to do stuff with it. This code is the code that comes with flash chat. I kinda hacked it up too.

I figured a way....the main tpl file index2.tpl that is in the code...I can edit that into table and it makes it look a lot better.

thanks for the help

This website is proudly hosted on Crocweb Cloud Website Hosting.