PDA

View Full Version : PHP Code in header basics


delay
Tue 25th Jul '00, 2:31pm
I am trying to get some php code to execute in the header. I am new to php so I am probably doing something dumb. How do you make php execute in the headers or templates in vbulletin. For my banner program I have to generate a random number in my banner code for each banner display. I was going to use this code to generate the random number.

<?php $rndnumber=(mt_rand() % 100000-1) + 1;
echo "$rndnumber";
?>

It works fine on a regular php page but not within the vbulletin header. Is this because $header is called as a variable from within another template? Is there any way to have this code execute in vbulletin?

Thanks for any info...
-Delay

MattR
Wed 26th Jul '00, 11:08pm
Delay,
You have to turn on "Parse Header for PHP" in the Admin options. And then you need to remove anything else that is non-php in the header and use echos or whatnot to get it out.

delay
Thu 27th Jul '00, 12:12am
Thanks mrogish!

Worked great once I updated the options. Only one other thing for anyone else looking to do this. Don't put the code in <?php ?> tags or it will give you errors just put in code directly.

Thanks again...

-Delay

MattR
Thu 27th Jul '00, 12:17am
No problem! Now if I could figure what happened with our damn DB then I will be a happy guy!