MyBB Community Forums

Full Version: Adding PHP include to a header
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi,

i'm having some problems including a random quote generator php file into my heading.

the php file, reads a db, gets a random quote out, and displays it suing an echo.

when i try to add the following to the heading template

<?php include("/path/to/your/random-quote-script.php"); ?>


nothing happens.

does it not read <?php tag? please help. how do i get my php "echo" to show up?

Thanks!
You can't use PHP in templates; probably 50threads about it ... Put in into your global.php and create a var with the output that you can use in your header template.
i'm very bad at all this, i was wondering if i could get some help.

i'm not sure if id id it right or not, but i put

$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to MySQL.');

mysql_select_db(DATABASE_NAME);

$query = "SELECT id,IP, USER_NM, TIME, QUOTE FROM Quotes ORDER by rand() LIMIT 1";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {
echo "<p><i>aaaaaaaa" , ($row['QUOTE']) , "bbbbbbbb</i></p>";
echo "document.write('", ($fow['QUOTE']), "Hello World');";
}

mysql_free_result($result);
mysql_close();
in my global.php

so i'm assuming RESULT is the variable i should be using in the template?
how do i reference it? or maybe i'm didn't completly understand this.

Thanks!

sorry if i'm being redundant about this.
well. i also wanted to add a text box, at the footer, so that the users can enter their own quotes to be displayed in the header, would this be possible without me being able to include the php?