Hi,
I wanted to add some php-content to my template.html using the following "trick":
I have a file called "dates.php" and the template.html, where I added my header into the code. In one particular <tr> of the header I wanted to include the dates.php-file.
So I thought this could work: In the Control Panel I declared the URL www.mysite.com/dates.php as a Custom Header and added the link {CUSTOM_HEADER} to the <tr> in the template.html.
So my intention was that the dates.php is shown instead of {CUSTOM_HEADER}, but that's not the case. Where did I go wrong?
You need to specify a path, not an URL. If that doesn't help then post a link and your code.
Many thanks,
I specified the path, so the php file is now found, but instead I get an error. The php file looks like this:
<?php
echo <<<EOT
.....some php code here.....
EOT;
?>
and I get the error message:
Parse error: parse error, unexpected $ in /homepages/46/d19447377/htdocs/gallery/header.php on line 9
which is the last line ?>
I also tried to leave everything blank in between EOT, same error. Any ideas?
Make sure you don't have any whitespace immediately after (on the same line as) the EOT;
You mean like this?
....php code......
EOT;?>
I tired that but same error. This is confusing. ???
Can you post the actual code?
OK, this is what the header.php (I renamed it that way) looks like, that I want to add with {CUSTOM_HEADER} into template.html:
<?php
echo <<<EOT
$DatabaseHost = "xxxx";
$DatabaseUser = "xxxx";
$DatabasePassword = "xxxx";
$Database = "xxxx";
$TableDates = "Dates";
MYSQL_CONNECT($DatabaseHost, $DatabaseUser, $DatabasePassword) or die ( "Datenbankserver nicht erreichbar");
MYSQL_SELECT_DB($Database) or die ( "Datenbank nicht vorhanden");
$Result=MYSQL_QUERY( "SELECT Datum, Ort, CURRENT_DATE, DATE_FORMAT(Datum, '%d.%m.') as 'DateFormat' FROM $TableDates
WHERE CURRENT_DATE < Datum ORDER BY Datum DESC LIMIT 6
");
if(mysql_num_rows($Result)>0)
{
for($i=0; $i<mysql_num_rows($Result); $i++)
{
$Daten = mysql_fetch_object($Result);
echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr>",
"<td>",
$Daten->DateFormat,
"</td>",
"<td> ",
"</td>",
"<td>",
$Daten->Ort,
"</td>",
"</tr>",
"</table>";
}
}
else
{
echo"Keine aktuellen Dates in der Datenbank.";
}
echo"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">",
"<tr>",
"<td> ",
"</td>",
"</tr>",
"<tr>",
"<td><a href=\"contact.php\">Contact und Booking</a>",
"</td>",
"</tr>",
"</table>";
EOT;?>
You need a new line after the EOT; but no space between the semi colon and the newline.
Many thanks for your fast answers, I really appreciate it!
Now there's no error message, but in the table where the php-stuff should be it shows only {CUSTOM_HEADER}.
I think we're close, maybe I have to alter the table in the template.html somehow?
It looks like this:
<tr>
<td bgcolor="#002200" align="left">{CUSTOM_HEADER}</td>
</tr>
Make sure your {CUSTOM_HEADER} is above {GALLERY}. If it is not then you need to use a custom footer instead.
Thanks again, it worked...almost worked.
What happened now is that the php code of the Custom Footer is shown in clear letters inside the table.
Please take a look at the code above, how do I have to change notation to make it work?
Many thanks so far
-Kid
OK, problem solved!
I just removed the EOT-Tags....and it worked. Thought this notation was mandatory for the custom header/footer, but it seems I got something wrong at that point in the FAQ.
Thanks to Nibbler, you have been a great help. :)