PHP Coding Project 1 Page19

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

PHP Coding Project 1 Page19

Postby seancyril » Fri Jul 23, 2010 6:10 pm

Hi, I am a total newb when it comes to programming and was really enjoying the php coding academy in this month's mag until I ground to a halt at page 19.
I have input the following to project1.php
<?php
$files=scandir(".");
foreach ($files as $file {
print "$file\n";
}

?>
When I try and run the script I get the following error message

PHP Parse error: syntax error, unexpected ';' in /home/sean/PHP/project1.php on line 4
Please can anyone advise me as to what I am doing wrong? I believe I have input exactly what was stated in the magazine. I am obviously doing something wrong so any advice would be much apprectiated

thanks
Sean
seancyril
 
Posts: 18
Joined: Sat Mar 13, 2010 12:08 pm

Postby Ram » Fri Jul 23, 2010 11:16 pm

Your missing a closing ) in your foreach loop:

Code: Select all
<?php
$files=scandir(".");
foreach ($files as $file) {
print "$file\n";
}

?>

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
User avatar
Ram
LXF regular
 
Posts: 1674
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Postby seancyril » Sat Jul 24, 2010 5:40 pm

Of course! Thanks for that. I'm really enjoying learning about coding. I can crack on with the rest of the booklet now
Sean
seancyril
 
Posts: 18
Joined: Sat Mar 13, 2010 12:08 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests