Re: Parse error: syntax error, unexpected ',' in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/05/06, Mark Sargent <powderkeg@xxxxxxxxxxxxxxxx> wrote:
Hi All,

this code,

<?php
$flavour[] = "blue raspberry";
$flavour[] = "root beer";
$flavour[] = "pineapple";
sort($flavour);
print_r($flavour);
echo "<br>";
echo "My favourite flavours are:<br>";
     foreach ($flavour as $currentValue) {
        //these lines will execute as long as there is a value in $flavour
        echo $currentValue "<br>\n";
     }
?>


gives this,

*Parse error*: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING,
expecting ',' or ';' in */usr/local/apache2/htdocs/sorting.php* on line *18

*
and adding a , to this line,

       foreach ($flavour, as $currentValue) {

No, you were right the first time. No comma is required there.

Line 18 is the line with the echo statement on it. The items you want
to echo should be separated by commas:

So it should be:

       echo $currentValue, "<br>\n";

-robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux