tags:

views:

69

answers:

3

im getting this error:

Parse error: syntax error, unexpected T_ECHO in /home/labvc/public_html/AT/site/getimages.php on line 26

from this code:

<?php

echo '<br />';
echo '<div id=gallery>';

function getDirTree($dir,$p=true) {
    $d = dir($dir);$x=array();
    while (false !== ($r = $d->read())) {
        if($r!="."&&$r!=".."&&(($p==false&&is_dir($dir.$r))||$p==true)) {
                $x[$r] = (is_dir($dir.$r)?array():(is_file($dir.$r)?true:false));
        }
    }

    foreach ($x as $key => $value) {
        if (is_dir($dir.$key."/")) {
                $x[$key] = getDirTree($dir.$key."/",$p);
        }
    }

    ksort($x);
    return $x;
}

$tree = getDirTree("./res/gallery/painting/");

foreach($tree as $element => $eval) {
    if (is_array($eval)) {
        foreach($eval as $file => $value) {
                if (strstr($file, "png")||strstr($file, "jpg")||strstr($file, "bmp")||strstr($file, "gif")) {
                        $item = $tree.'/'.$element.$file;
      $itemthumb = $tree.'/thumbs/'.$element.$file;
                        echo '<a href="'.$item.'"><img src="'.$itemthumb.'" alt="'.$file.'"/></a>';
                }
        }
    }
}

echo '</div>';


echo '<br />';

echo 'tree: '.$tree.'<br />';
echo 'element: '.$element.'<br />';
echo 'file: '.$file.'<br />';

$abc="res/gallery/painting";
$def="01.png";
echo'<a href="'.$abc.$def.'"><img src="'.$abc.'/thumbs/'.$def.'" alt="'.$def.'"/></a>';

echo '<br />';

line 26 is not an echo, theres not even an echo close to line 26

foreach($tree as $element => $eval) {

Any ideas?

A: 

yup. that's not the file.

just somebody
eh? what do you mean?
Brae
the file you posted is not `/home/labvc/public_html/AT/site/getimages.php`, or it's the right path, but from a wrong host.
just somebody
it was the right path, read the other comments.
Brae
ah, ok then. you asked for ideas, i gave mine. ;)
just somebody
+6  A: 

I know it sounds silly, but are you actually looking at / editing the file you are debugging?

Any number of times it turned out I was in directory A/foo.c, when the code was being run out of directory B/foo.c. I always feel stooooopid after doing this.

Stick a print "foo!" in there to see if you are actually in the file you think you are.

Peter Rowell
how very bizare, for some reason my other fileuploads to my server worked fine, but this one failed even though the transfer says it completed, so i deleted the one on the server, refreshed and reuploaded, now its working, thanks for the help :P
Brae
You're welcome. By the way, I've noticed that the probability of doing this particular stupid thing goes up exponentially after I've been working for more than 8 hours, sort of O((h-8)^2). I stopped pulling all-nighters 20 years ago when I started factoring in all the time it took the next day to fix all of the *clever* things I had done the night before.
Peter Rowell
Bahaha nice, i'm not at that stage yet, i make plenty good progress if i stay up, for example, two days ago i knew nothing about php, now i have basically swapped all my work over to it (php is awesome)
Brae
Ah, Grasshopper, but Python is more awesomer! (?)Be careful about mixing your Business logic with your Presentation logic in your PHP pages. The language makes it *so* easy to do and it's a really bad habit to get into.
Peter Rowell
A: 

This seems a suspicious line:

$item = $tree.'/'.$element.$file;

$tree should be an array, so if you get the error at runtime (as opposed to compile time) then it would make sense it would complain about this.

wallyk
nah i worked it out, my ftp client doesnt auto update the local list, so it tryed to upload a phantom version of my file, so no updates occured.
Brae