Jump to content

variables, semicolons, and brackets


Asday

Recommended Posts

<?php
// ...
for($x=($piccies=(scandir("upld194")))) // line 22
// ...
?>

 

Produces:

 

Parse error: syntax error, unexpected ')', expecting ';' in C:\xampp\htdocs\new\index.php on line 22

 

And I can't, for the life of me, work out where to put the stuff.

 

Halp, please.

Link to comment
Share on other sites

Well, I would advise against putting all that on one line as it is not easy to read and undersand what is going on. It might be when you are writing it, but for an outsider or yourself going through it at a later date it may be more difficult.

 

The problem, I believe, is that you are using a for loop instead of a foreach loop. A for loop takes three parameters separated by a semicolon. You are dealing with an array, so you want a foreach loop. Try this:

 

foreach(scandir("upld194") as $x)

Link to comment
Share on other sites

Well, I would advise against putting all that on one line as it is not easy to read and undersand what is going on. It might be when you are writing it, but for an outsider or yourself going through it at a later date it may be more difficult.

 

The problem, I believe, is that you are using a for loop instead of a foreach loop. A for loop takes three parameters separated by a semicolon. You are dealing with an array, so you want a foreach loop. Try this:

 

foreach(scandir("upld194") as $x)

 

That was the problem, thanks.

 

It all werks now.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.