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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 500
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 113
  • Total: 113

Can I put an include file somewhere

Started by Z.O.D, May 14, 2010, 12:16:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Z.O.D

Can I put an include file somewhere so my php block can grab data from it?

JPDeni

Yes. You should probably put it in your Sources directory, which will allow you to use something like


include "file.inc";


The Sources directory is the current directory when a block is evaluated. If you don't want it to be in that directory, you either will need to use the whole path (not URL!) to the file or use a path that is relative to the Sources directory.

Z.O.D

#2
Awesome, can I use an absolute path?

This is what I put before the doc type right

<?php
include('/home/content/mysite/html/locationtofile/blahblah.php')
?>

Oh, okay, you mean put my file in the sources directory and use a relative path, gotchya :D..Thanks for that! Ill give it a try.

JPDeni

Don't use the


<?php


and


?>


The code in a php block is executed by way of an "eval" function, so you don't use those like you would in a separate file.

Z.O.D

#4
So I don't use any php tags in all of my code? Im getting an error unexpected <

Im getting this error now

Parse error: syntax error, unexpected '<' in /home/content/mysite/html/forum/Sources/Load.php(1967) : eval()'d code(48) : eval()'d code on line 3

Z.O.D

Is it stricly php only? cant I have html in there as well?

JPDeni

You can have html, but don't put the tags at the beginning or the end. You can have them in the middle as you would for a regular file.

If you can't figure it out, post your full code (use code tags -- the # button on the reply screen) and I'll see if I can help you with it.

Z.O.D

that'd be awesome if you could help me please :D..THanks so much for your help!


include "_ott_header.php";

<center><br />
<font color="#FFFF00" size="4">Bock<br /><br />
~~~~~~~~~~~<br /><br />
<font color="#66CC00" size="4"><b><i><center> BlockCR($dbPre, $dbPre2, $conn, $conn2);<br />( BlockCRDTG($dbPre, $dbPre2, $conn, $conn2);  to go!)</center></i></b></font><br />
~~~~~~~~~~~<br /><br />
Next 5</font><br /><br />
<font color="#cccccc" size="3"> BlockNF($dbPre, $dbPre2, $conn, $conn2); </font>
</center>


JPDeni



include "_ott_header.php";
?>

<center><br />
   <font color="#FFFF00" size="4">Bock<br /><br />
   ~~~~~~~~~~~<br /><br />
   <font color="#66CC00" size="4"><b><i><center> BlockCR($dbPre, $dbPre2, $conn, $conn2);<br />( BlockCRDTG($dbPre, $dbPre2, $conn, $conn2);  to go!)</center></i></b></font><br />
   ~~~~~~~~~~~<br /><br />
   Next 5</font><br /><br />
   <font color="#cccccc" size="3"> BlockNF($dbPre, $dbPre2, $conn, $conn2); </font>
</center>
<?php



I'm not sure what the BlockCR thing is. Is that a javascript? Or, in the original code are there more times that <?php and ?> are used that you took out? If there are, this won't work. Post the whole original code.

Z.O.D

Yeah sorry, I thought you said to take that stuff out..I gave the modified code from my block, heres the original


include "_ott_header.php";
<center><br />
<font color="#FFFF00" size="4">Block<br /><br />
~~~~~~~~~~~<br /><br />
<font color="#66CC00" size="4"><b><i><center><?php BlockCR($dbPre$dbPre2$conn$conn2); ?><br />(<?php BlockCRDTG($dbPre$dbPre2$conn$conn2); ?> to go!)</center></i></b></font><br />
~~~~~~~~~~~<br /><br />
Next 5</font><br /><br />
<font color="#cccccc" size="3"><?php BNF($dbPre$dbPre2$conn$conn2); ?></font>
</center>

This website is proudly hosted on Crocweb Cloud Website Hosting.