4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: rp on February 08, 2003, 09:08:47 PM

Title: Parse Error in includes/template.php
Post by: rp on February 08, 2003, 09:08:47 PM
Hallo

Ich habe auf meinen Templates folgenden Code eingebunden, welcher ein Zufallsbild erzeugen soll:

Code: [Select]
<?php
$imgpath 
"/home/virtual/site9/fst/var/www/html/graphics/rnd_a";
$handle opendir&#40; "$imgpath" &#41;;

$imgArray = array&#40;&#41;;

while&#40;$file = readdir&#40;$handle&#41;&#41;
&#123;
    
if&#40; $file != "." && $file != ".." &#41;
    
&#123;
        
array_push&#40; $imgArray, $file &#41;;
    
&#125;
&#125;
closedir&#40; $handle &#41;;

mt_srand&#40; &#40;double&#41;microtime&#40; &#41; * 1000000 &#41;;
$randval mt_rand&#40; 0, sizeof&#40; $imgArray &#41; - 1 &#41;;

print&#40; "<img src=\"/graphics/rnd_a/" . $imgArray[ $randval &#93; . "\" width=\"200\" height=\"85\">" &#41;;
?>


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
Title: Parse Error in includes/template.php
Post by: rp on February 09, 2003, 04:54:16 PM
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):

Code: [Select]
<?php 
$imgpath 
"/home/virtual/site9/fst/var/www/html/graphics/rnd_a"
$handle opendir&#40; "$imgpath" &#41;; 

$imgArray = array&#40;&#41;; 

while&#40;$file = readdir&#40;$handle&#41;&#41; 
&#123; 
    
if&#40; $file != "." && $file != ".." &#41; 
    
&#123; 
        
array_push&#40; $imgArray, $file &#41;; 
    
&#125; 
&#125; 
closedir&#40; $handle &#41;; 

mt_srand&#40; &#40;double&#41;microtime&#40; &#41; * 1000000 &#41;; 
$randval mt_rand&#40; 0, sizeof&#40; $imgArray &#41; - 1 &#41;; 

print&#40; "<img src=\"/graphics/rnd_a/" . $imgArray[ $randval &#93; . "\" width=\"200\" height=\"85\">" &#41;; 
?>


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
Title: Parse Error in includes/template.php
Post by: V@no on February 09, 2003, 05:17:44 PM
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:
Code: [Select]
hello <?php
echo "hi";
?>
bye

but this code will work:
Code: [Select]
hello
<?php
echo "hi";
?>

bye
Title: Parse Error in includes/template.php
Post by: rp on February 09, 2003, 06:52:20 PM
Thank you V@no

When I put <?php and ?> on a new line it works.