Re: Help with file reads
From: Andy Hassall (andy_at_andyh.co.uk)
Date: 12/24/03
- Next message: I Report, You Decide: "Why does Perl use more resource than Php?"
- Previous message: Dark Angel: "Re: strtolower wont do his job"
- In reply to: KB: "Re: Help with file reads"
- Next in thread: KB: "Re: Help with file reads"
- Reply: KB: "Re: Help with file reads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 23 Dec 2003 23:31:25 +0000
On 23 Dec 2003 15:14:24 -0800, rascal329@hotmail.com (KB) wrote:
>Newsgroups: alt.php
>
>Thanks for the help guys. I tried to make this work using your
>suggestions but didn't get anywhere. Here is my code in it's
>entirety. It still gives me the same parse error of unexpected "]",
>like it's expecting a variable and doesn't know how to deal with the
>auto incrementing.
>
>
><html>
><head>
><title>imageIndex</title>
></head>
><body>
>
><?
>// image index
>// generates an index file containing all images in a particular
>directory
>
>//point to whatever directory you wish to index.
>//index will be written to this directory as imageIndex.html
>$dirName = "D:\hshome\boone\kbent.com\images\";
Here's your problem. Inside "" double quotes, \ is used as an 'escape
character'. You use it if you want to use certain characters such as newlines
(\n), or double quotes inside the double quotes, where you use \".
So the \" at the end actually turns into a literal " _inside the string_, and
now there's no terminating " to actually end the string. What this can then do
is turn the rest of your script into part of the string being assigned to
$dirName!
It'd then fail here:
$theFiles[]
... on the ], because inside a string, if you're using an array, you have to
give it an array subscript to read from.
Basically, \ as a directory separator on Windows often causes awkwardness
since it clashes with the escape character. Windows accepts Unix-style '/'
slashes as a directory separator just as well, so either:
(a) Use single quotes (most escape sequences aren't translated in single
quotes):
$dirName = 'D:\hshome\boone\kbent.com\images\';
(b) Escape the \'s (again using \):
$dirName = "D:\\hshome\\boone\\kbent.com\\images\\";
(c) Use / instead:
$dirName = "D:/hshome/boone/kbent.com/images/";
or
$dirName = 'D:/hshome/boone/kbent.com/images/';
-- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
- Next message: I Report, You Decide: "Why does Perl use more resource than Php?"
- Previous message: Dark Angel: "Re: strtolower wont do his job"
- In reply to: KB: "Re: Help with file reads"
- Next in thread: KB: "Re: Help with file reads"
- Reply: KB: "Re: Help with file reads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|