create file and write content in same code block



This a modified part of a larger script I made. I couldn't get it
working so I made a smaller part of it - hoping to get it working.
Well it still doesn't work :(
The following code creates the new file, but does not write the
$content strings to the file. It then prints "Did nothing!" instead of
"done!".

<?php

$word = "2002";

$content1 = "one ";
$content2 = "two ";
$content3 = "three";

$fileName = '/home/leke/www/dic/' . $word . '.html';
$handle = fopen($fileName, 'w');
if (file_exists($fileName)) {
print "Did nothing!";
}
else
{
fwrite($handle, "$content1 . $content2 . $content3");
fclose($handle);
print "done!";
}
?>

I cant figure out the problem. Can anyone help me and maybe explain
what went wrong?
Thanks :)
.



Relevant Pages

  • Re: Help formatting a mysql query string
    ... > The PHP way is awful (you have to escape your strings and ... > The last variant has a security vulnerability: ... I normally work with php ... >> script is parsing a web page and getting the field headings (which will ...
    (comp.lang.python)
  • Session losing variables?
    ... I have a script start.php and a second script proceed.php ... <?PHP ... // Strings match, so open logfile, exit if this fails. ...
    (comp.lang.php)
  • How resource-intensive are these?
    ... I'm writing a fun little php script that generates a random image by ... stringing together 8 smaller images. ... The way the script is set up now, I am generating strings by grabbing ...
    (alt.php)
  • Re: Session losing variables?
    ... I have a script start.php and a second script proceed.php ... <?PHP ... // Store these vars in the SESSION array. ... // Strings match, so open logfile, exit if this fails. ...
    (comp.lang.php)
  • Re: php mail()
    ... > I cant get the mail function in php to work. ... > with the mailfunction, the script is just sleeping, doing nothing. ... > Have enabled debug in php, ...
    (freebsd-questions)