kalm1234 Posted January 12, 2009 Share Posted January 12, 2009 this script also contains HTML, just so you know Anyway, i've tried to find my error in this script, but have been unable to do so... Thanks for any help given 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. Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/ Share on other sites More sharing options...
DarkSuperHero Posted January 12, 2009 Share Posted January 12, 2009 <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> Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735724 Share on other sites More sharing options...
DarkSuperHero Posted January 12, 2009 Share Posted January 12, 2009 <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; Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735725 Share on other sites More sharing options...
kalm1234 Posted January 12, 2009 Author Share Posted January 12, 2009 Thanks so much! I have a problem looking over stuff, always missing minor details. Where was the bracket missing at? Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735733 Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 else { $fp = fopen($title,"a+"); } Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735767 Share on other sites More sharing options...
DarkSuperHero Posted January 13, 2009 Share Posted January 13, 2009 good deal :-) glad to be able to help.... Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735772 Share on other sites More sharing options...
Reaper0167 Posted January 13, 2009 Share Posted January 13, 2009 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.'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/140587-php-script-help/#findComment-735779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.