Jump to content

PHP script help


kalm1234

Recommended Posts

this script also contains HTML, just so you know  :P

 

Anyway, i've tried to find my error in this script, but have been unable to do so...  Thanks for any help given ;D

 

This is the error I got when i tried to run it on my server:

 

"Parse error: syntax error, unexpected $end in /test.php on line 31"

 

<html>

<head>

</head>

<body bgcolor=#336699>

<center><h2>Your page is being retrieved...</h2></center>

 

<?php

 

$title = $_POST['title'];

 

if (!file_exists($title)) {

    echo 'The file you tried to edit does not exist!';

exit;

} else {

 

$fp = fopen($title,"a+");

 

if(!$fp) {

    echo 'Error, the file could not be opened or there was an error when creating it.';

    exit;

}

 

$content = fread($fp, filesize($title));

fclose($fp);

 

echo "<form action='edit.php' method='post'><input type='hidden' name='title'

value='".$title."'>Title (eg. index.html, index.php) <input type='text' name='title' value=''><p><textarea rows='20' cols='100' name='content'>".$content."</textarea><br><p><input type='submit' value='Save Page'></center></form>";

 

?>

 

</body>

</html>

 

I tried putting the code in a code box, but it wouldn't work for some reason, sorry.

Link to comment
Share on other sites

<html>
<head>
</head>
<body bgcolor=#336699>
<center><h2>Your page is being retrieved...</h2></center>

<?php

$title = $_POST['title'];

if (!file_exists($title)) {
    echo 'The file you tried to edit does not exist!';
exit;
} else {

$fp = fopen($title,"a+");

if(!$fp) {
    echo 'Error, the file could not be opened or there was an error when creating it.';
    exit;
}

$content = fread($fp, filesize($title));
fclose($fp);

echo "<form action='edit.php' method='post'><input type='hidden' name='title' 
value='".$title."'>Title (eg. index.html, index.php) <input type='text' name='title' value=''><p><textarea rows='20' cols='100' name='content'>".$content."</textarea><br><p><input type='submit' value='Save Page'></center></form>";

?>

</body>
</html>

Link to comment
Share on other sites

<html>
<head>
</head>
<body bgcolor=#336699>
<center><h2>Your page is being retrieved...</h2></center>

<?php

$title = $_POST['title'];

if (!file_exists($title)) {
    echo 'The file you tried to edit does not exist!';
} 
else {
$fp = fopen($title,"a+");
}

if(!$fp) {
    echo 'Error, the file could not be opened or there was an error when creating it.';
}

$content = fread($fp, filesize($title));
fclose($fp);

echo "<form action='edit.php' method='post'><input type='hidden' name='title' 
value='".$title."'>Title (eg. index.html, index.php) <input type='text' name='title' value=''><p><textarea rows='20' cols='100' name='content'>".$content."</textarea><br><p><input type='submit' value='Save Page'></center></form>";

?>

</body>
</html>

 

try that.. :-) missing a bracket, and i dont really think you need the exit;

Link to comment
Share on other sites

i don't know a whole of php stuff like lots of others on this site...but one thing i do is set up my code this way, so i can easily spot things out like that. just trying to help

<?php
$title = $_POST['title'];

if (!file_exists($title))
{
    echo 'The file you tried to edit does not exist!';
} 
else
{
    $fp = fopen($title,"a+");
}

if(!$fp)
{
    echo 'Error, the file could not be opened or there was an error when creating it.';
}
?>

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.