By Nomex on
I downloaded a non-drupal php script that randomly display images. (I have used it on regular php sites fine.) however, when i inserted it into my drupal front page I get an error stating:
"Parse error: syntax error, unexpected T_STRING in /home/tastean/public_html/includes/common.inc(1347) : eval()'d code on line 9"
I am not a php expert so I hope someone out there know's what the hell i am babbling on about. below is the php code i used:
<?php
//You will have to change the ban1, ban2, and ban3 variables. You can change these links to point at the images
you want displayed.
//You will have to change the url1, url2, and url3 variables. You want these to be urls of the pages you want to
link to.
$ban1 = "http://www.tasteantigua.com/files/1.gif";
$url1 = "http://www.mcdonalds.com";
$ban2 = "http://www.tasteantigua.com/files/2.gif";
$url2 = "http://www.olivegarden.com/";
$ban3 = "http://www.tasteantigua.com/files/3.gif";
$url3 = "http://www.starbucks.com/";
$ban4 = "http://www.tasteantigua.com/files/4.gif";
$url4 = "http://www.kfc.com/";
//Random number between 1 and number of banners.
$randomNum = rand (1,4);
//Select the banner of the random number
$image = ${'ban'.$randomNum};
//Url of the random number
$url= ${'url'.$randomNum};
//Prints out the link of the banner and the image of the banner
Print "<a href=".$url." mce_href=".$url."><img src=".$image." border=0></a>";
?>
Comments
=-=
A parse error is usually a typo. Now looking at what you posted above, it seems that there is some kind of spacing in the comments which isn't any good and part of your comments were sent to another line. compare your code snippet above and mine below. Specially the first two comments in the snippet.
check your script for spacing issue. Though this may not be your problem. Compare the code below with what yours.
ie:
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
Comments not commented
To fix your problem you need to make sure that every comment line starts with //
for more info google "php comments"
The code is OK. It is just some of the comment lines have continued onto a new line when you pasted it in.
gpdinoz
"Everything should be made as simple as possible, but not simpler." - Albert Einstein
Regards
Geoff
=-=
The second comment line in the beginning of the code also has spacing issues. "link to." is also on a new line and shoudln't be.
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
Thanks a Mil
To everyone that chipped in Big Shout outs!
The code was the problem and it just needed some cleaning up it appears, now everything works like a charm. The Drupal community rocks because of you guys.
Thanks again.