Parse error - Newbie
Posted: Fri Mar 28, 2008 1:41 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I am trying to use a form to create a new file.
With some help I got the form and the php process to create a file in a subdirectory. Then I tried to add code to see if a file of the same name exists in the directory and avoid overwriting it.
This is the php process code:
When I run the program, I get this error:
Parse error: parse error in /home/a/a/xxxxx.org/html/test2.php on line 19
Can anyone tell me where I am going wrong?
Thanks in advance
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I am trying to use a form to create a new file.
With some help I got the form and the php process to create a file in a subdirectory. Then I tried to add code to see if a file of the same name exists in the directory and avoid overwriting it.
This is the php process code:
Code: Select all
<?php
$pagename = $_POST["pagename"]; // gets the form variable if globals are on or off
$copyFrom = "templates/pagetemplate.php";
$pagename_2 = $pagename.".php";
$filename = '/test_content/$pagename_2;
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
$copyTo = "test_content/" . $pagename . ".php";
$hasItWorked = copy($copyFrom, $copyTo);
if($hasItWorked) echo "IT HAS WORKED!";
if(!$hasItWorked) echo "DOH! IT HASN'T WORKED!";
}
?>
<br>
<?php
$pagename_2 = $pagename.".php";
echo $pagename_2;
?>
Parse error: parse error in /home/a/a/xxxxx.org/html/test2.php on line 19
Can anyone tell me where I am going wrong?
Thanks in advance
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: