Can I put an include file somewhere so my php block can grab data from it?
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.
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.
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.
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
Is it stricly php only? cant I have html in there as well?
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.
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>
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.
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>
Just the first and last ones need to go. This should work. If it doesn't, let me know and I'll fix it another way.
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>
<?php
Parse error: syntax error, unexpected $end in /home/content/mysite/html/forum/Sources/Load.php(1967) : eval()'d code(48) : eval()'d code on line 11
Guess I should tel you what version I am using aye..lol
SMF 1.1.11
and TP is 1.0 Beta 4
Try this. (I don't like dealing with embedded html if I can get away from it. It's too confusing.)
include "_ott_header.php";
echo '
<center><br />
<font color="#FFFF00" size="4">Block<br /><br />
~~~~~~~~~~~<br /><br />
<font color="#66CC00" size="4"><b><i><center>';
BlockCR($dbPre, $dbPre2, $conn, $conn2);
echo
'<br />(';
BlockCRDTG($dbPre, $dbPre2, $conn, $conn2);
echo
'to go!)</center></i></b></font><br />
~~~~~~~~~~~<br /><br />
Next 5</font><br /><br />
<font color="#cccccc" size="3">';
BNF($dbPre, $dbPre2, $conn, $conn2);
echo '</font>
</center>';
Fatal error: Call to undefined function SponsorLine() in /home/content/mysite/html/forum/Sources/_ott_header.php on line 10
And the forum didnt load, only the blocks loaded.
This is in my php file
<?php
// sessions
session_start();
header('Cache-control: private');
// functions
include('_ott.php');
// check for next in line
SponsorLine($dbPre, $dbPre2, $conn, $conn2);
// validate post
$_POST = validate_post($_POST);
?>
mmm, maybe I need to add my other include file in this file to the sources folder as well?
EDIT: YUP IT WORKS :D lol...awesome...thank you soooo mcuh JPDeni : )
I'm glad you got it figured out. :) I'll mark it solved.
:smitten:
Cant wait to update TP and SMF to this forum, this forum flys!!!!!!!!!Mine is soooo slow!!!!!
I love this forum...