Author Topic: Parse Error in includes/template.php  (Read 4714 times)

0 Members and 1 Guest are viewing this topic.

Offline rp

  • Newbie
  • *
  • Posts: 36
    • View Profile
Parse Error in includes/template.php
« 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

Offline rp

  • Newbie
  • *
  • Posts: 36
    • View Profile
Parse Error in includes/template.php
« Reply #1 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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Parse Error in includes/template.php
« Reply #2 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
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline rp

  • Newbie
  • *
  • Posts: 36
    • View Profile
Parse Error in includes/template.php
« Reply #3 on: February 09, 2003, 06:52:20 PM »
Thank you V@no

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