parse error, expecting `';''.where?

Discussion in 'PHP' started by Krest_0, Sep 19, 2009.

  1. #1
    Hi! maybe my English is not perfect, but anyway, I've this problem with php:
    in this script I want to calculate the number of images are inside a folder(path-->thumbs/foto/). But when I try to use it I receive this error:

    "Parse error: parse error, expecting `';'' in C:\wamp\www\gallery\gallery_visual.php on line 21".

    I can't understand where I have to put this damn ";". Of course I'm not a boss about php.....

    Some ideas?

    Thank a lot!


    <?php
    $nome_cartella = "thumbs/foto/";
    $handle = opendir($nome_cartella);
    while (false != ($file = readdir($handle))) {

    if ( $file == ".." || $file == ".") {
    $fotografie=Array($file);
    $number=count($fotografie);
    for (i=0; i<=$number; i++){
    echo $fotografie;
    }


    ?>
     
    Krest_0, Sep 19, 2009 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    The problem here is with the For Loop
    
    for (i=0; i<=$number; i++){
    echo $fotografie[i];
    }
    
    
    PHP:
    While it's supposed to be:

    
    for ($i=0; $i<=$number; $i++){
    echo $fotografie[$i];
    }
    
    
    PHP:
    Oh and you've forgotten to close the "{"

    
    <?php
    $nome_cartella = "thumbs/foto/";
    $handle = opendir($nome_cartella);
    while (false != ($file = readdir($handle))) {
    
    if ( $file == ".." || $file == ".") {
    $fotografie=Array($file);
    $number=count($fotografie);
    for (i=0; i<=$number; i++){
    echo $fotografie[i];
    }
    }
    }
    
    
    ?> 
    
    
    
    PHP:
     
    Oli3L, Sep 19, 2009 IP
  3. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #3
    what do you mean by while (false != ($file = readdir($handle)))??

    can I see line 21?
     
    astrazone, Sep 19, 2009 IP
  4. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #4
    u need to add } and } again to close your loop ... :)

    regards
     
    ghprod, Sep 21, 2009 IP
  5. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try this code:

    <?php
    $nome_cartella = "thumbs/foto/";
    
    $handle = opendir($nome_cartella);
    while (false != ($file = readdir($handle))) {
    	if ( $file == ".." || $file == ".") {
    		$fotografie=Array($file);
    		$number=count($fotografie);
    
    		for ($i=0; $i<=$number; $i++) {
    			echo $fotografie[i];
    		}
    	}
    }
    ?>
    PHP:
    Formatted
     
    Martinoes, Sep 24, 2009 IP