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
https://forums.phpfreaks.com/topic/140587-php-script-help/
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
https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735724
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
https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735725
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
https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735779
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.