[PHP] Re: Cannot copy a file to a dynamic folder

2001-07-31 Thread Richard Lynch

 // Make new directory function
 $default_dir = (D:\www\Proj\$textfield2\);

The ()'s are silly... They force the string to be evaluated before any other
expressions in this statement, and there aren't any.

The \'s are bad, though.  \ is a special character inside of  and you
need to put \\ to get one \.  So, this line should be:

$default_dir = D:\\www\\Proj\\$textfield2\\;

An alternative is to just / like a real OS :-)
$default_dir = D:/www/Proj/$textfield2/;

Can't guarantee the trailing slash belongs there or not.  You'll have to try
both ways to be sure.

 if(file_exists($default_dir)) rmdir($default_dir);

This is technically okay, but sooner or later, you're going to need to do
more than just rmdir.  I'd recommend using:

if(file_exists($default_dir)){
rmdir($default_dir);
}

 mkdir($default_dir, 0777);

Logically, it might be better to test if the directory does *NOT* exist,
then make it.  Thus replace these two (well, four lines, now) with:

if (!file_exists($default_dir)){
mkdir($default_dir);
}

NOTE:  This will puke if D:\\www\\Proj doesn't already exist...  You may
want to add some error checking such as:

if (!file_exists($default_dir)){
if (!mkdir($default_dir)){
echo Could not create $default_dir.  Parent directory probably
doesn't exist.;
}
}

 // Copy template.html to new directory
 $filename = D:Automator\auto_2\Template.html;

You need quotes and \\ for each \ and you are missing a \ after D:
$filename = D:\\Automator\\auto_2\\Template.html;

 copy($filename, ($default_dir) .overview.html);

You need quotes around the overview.html part:
copy($filename, ($default_dir) . overview.html);

You may want to alter you php.ini file and use E_ALL (including E_NOTICE)
instead of the default setting -- A lot of the errors you are making would
be more clear if you did that.

 Can I not have these two scripts run together? The mkdir function alone
 works. Can someone tell me what I'm doing wrong?

I think I hit everything, but you never know for sure until it actually
works, eh?

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Cannot copy a file to a dynamic folder

2001-07-18 Thread elias

Hi!

when you use the \ character in a string you have to escape it by putting
\\ instead of one!

 $default_dir = (D:\www\Proj\$textfield2\);
would become:
$default_dir = D:\\www\\Proj\\$textfield2\\;

do the same for the $filename variable.

Vincent Chew [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I get a parse error every time and I've modified the scripts a bunch of
 times already.

 // Make new directory function
 $default_dir = (D:\www\Proj\$textfield2\);
 if(file_exists($default_dir)) rmdir($default_dir);
 mkdir($default_dir, 0777);

 // Copy template.html to new directory
 $filename = D:Automator\auto_2\Template.html;
 copy($filename, ($default_dir) .overview.html);

 Can I not have these two scripts run together? The mkdir function alone
 works. Can someone tell me what I'm doing wrong?

 Thank you.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]