4images Forum & Community
4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: rp on February 08, 2003, 09:08:47 PM
-
Hallo
Ich habe auf meinen Templates folgenden Code eingebunden, welcher ein Zufallsbild erzeugen soll:
<?php
$imgpath = "/home/virtual/site9/fst/var/www/html/graphics/rnd_a";
$handle = opendir( "$imgpath" );
$imgArray = array();
while($file = readdir($handle))
{
if( $file != "." && $file != ".." )
{
array_push( $imgArray, $file );
}
}
closedir( $handle );
mt_srand( (double)microtime( ) * 1000000 );
$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );
print( "<img src=\"/graphics/rnd_a/" . $imgArray[ $randval ] . "\" width=\"200\" height=\"85\">" );
?>
Dann erhalte ich folgenden Fehler:
Parse error: parse error, unexpected '<' in /home/virtual/site9/fst/var/www/html/galerie/includes/template.php(133) : eval()'d code on line 52
Auf all meinen anderen Seiten funktioniert das Skript für das Zufallsbild einwandfrei.
Bin dankbar für alle Hinweise
Gruss Romeo
-
Hello again
Here is the English translation. I hope this will help to solve my problem:
I'm trying to use the following code in my templates (for random image):
<?php
$imgpath = "/home/virtual/site9/fst/var/www/html/graphics/rnd_a";
$handle = opendir( "$imgpath" );
$imgArray = array();
while($file = readdir($handle))
{
if( $file != "." && $file != ".." )
{
array_push( $imgArray, $file );
}
}
closedir( $handle );
mt_srand( (double)microtime( ) * 1000000 );
$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );
print( "<img src=\"/graphics/rnd_a/" . $imgArray[ $randval ] . "\" width=\"200\" height=\"85\">" );
?>
This gives me the following error:
Parse error: parse error, unexpected '<' in /home/virtual/site9/fst/var/www/html/galerie/includes/template.php(133) : eval()'d code on line 52
On all my others pages of my homepage this little random script works perfectly.
Thank you for any help
Romeo
-
as far as I noticed u can not use <?php...?> if there is something else on same line.
for example this code won't work:
hello <?php
echo "hi";
?> bye
but this code will work:
hello
<?php
echo "hi";
?>
bye
-
Thank you V@no
When I put <?php and ?> on a new line it works.