PDA

View Full Version : PHP Include for ad system


Darwix
12-22-2005, 07:26 PM
I'm running into some problems including a banner rotation script on a forum.

If I put the advertisement code directly into the header template I get this error


The following error occurred when attempting to evaluate this template:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/talkhome/public_html/forum/includes/adminfunctions_template.php(3537) : eval()'d code on line 43

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.


I then tried pasting the code into a file called advert.php and including it in the header, this also did not work, it was just like it wasn't there at all. I'm stuck for now and any help would be greatly appreciated.

Thanks

Marco van Herwaarden
12-23-2005, 05:00 AM
The error probably means that you forgot a quote somewhere. Impossible to help more without seeing the actual code.

Darwix
12-23-2005, 10:57 PM
This is the code to include the ad


<?php
if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')) {
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:2', 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>

Andrew
12-24-2005, 12:05 AM
Try this instead:
<?php
if ((include getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php') == 'OK')
{
include (getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php')
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:2', 0, '', '', '0', $phpAds_context);
echo $phpAds_raw['html'];
}
?>

Darwix
12-25-2005, 11:40 PM
Thanks Andrew, unfortunately it didn't work. It's the same error as before.

Andrew
12-26-2005, 01:08 AM
Wow - I can't believe two of us missed this:
If I put the advertisement code directly into the header template I get this error
You can't put PHP directly into the templates :D What you will need to do is create a new plugin in global_start with the following code:

if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php'))
{
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:2', 0, '', '', '0', $phpAds_context);
$phpAdsVerify = "True";
}

Then add this to your header template where you want your ads to showup:

<if condition="$phpAdsVerify">$phpAds_raw['html']</if>

R34GTT
12-31-2005, 08:42 PM
Thank you for the above! I have now finally got my banner working!

imported_infitech
11-10-2006, 05:02 AM
Wow - I can't believe two of us missed this:

You can't put PHP directly into the templates :D What you will need to do is create a new plugin in global_start with the following code:

if (@include(getenv('DOCUMENT_ROOT').'/ads/phpadsnew.inc.php'))
{
if (!isset($phpAds_context)) $phpAds_context = array();
$phpAds_raw = view_raw ('zone:2', 0, '', '', '0', $phpAds_context);
$phpAdsVerify = "True";
}

Then add this to your header template where you want your ads to showup:

<if condition="$phpAdsVerify">$phpAds_raw['html']</if>

im getting The following error occurred when attempting to evaluate this template:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/infitech/public_html/forums/includes/adminfunctions_template.php(3593) : eval()'d code on line 6

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.