tempguy Posted October 31, 2010 Share Posted October 31, 2010 This should create a gb.txt in the local folder but its not creating it? What is wrong with it pls help <html> <head> <title>Guestbook</title> </head> <body> <?php extract($_REQUEST); ?> <?php if(isset($submit)) { saveGuestbook($name, $email, $comments); showGuestbook(); } elseif($check){ showGuestbook(); }else{ callForm(); } ?> <?php function showGuestbook() { echo "<body bgcolor='#DAE5CD'>"; echo "<font color='#cc3333' size='+2'><b>Thank You!</b></font> <br><br>"; $data = file("gb.txt"); foreach ($data as $line) { $line = rtrim($line); echo "<hr>"; list($name, $email, $comments) = split ("\t", $line); echo "Name: $name<br>"; echo "Email: $email<br>"; echo "Comments: $comments<br>"; } echo "<hr><p><a href = 'guestbook.php'>Click here </a> to go back </p>"; } function saveGuestbook($nam, $mal, $com) { $fh = fopen("gb.txt"); $nameData = $nam. "\t"; fputs($fh, $nameData); $mailData = $mal. "\t"; fputs($fh, $mailData); $commnetsData = $com. "\n"; fputs($fh, $commnetsData); fclose($fh); } function callForm() { print <<<DONE <font color="#CC0000" size="+2">Please sign our guestbook</font> <br > <br > <form name="Guestbook" method="post"> <table bgcolor="#DAE5CD"> <tr> <td valign="top">Name: </td> <td><input type="text" name="name" size="25" value="Your Name"></td> </tr> <tr> <td valign="top">E-mail:</td> <td><input type="text" name="email" size="25" value="[email protected]"></td> </tr> <tr> <td valign="top">Comments:</td> <td><textarea rows="5" cols="30" name="comments">Comments</textarea></td> </tr> <tr> <td></td> <td align="right"><input type="submit" name="submit" value="submit"> <input type="reset" value="Clear"> </td> </tr> </table> </form> <p>Want to check out our <a href="guestbook.php?check=check"> guestbook?</a></p> DONE; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2010 Share Posted October 31, 2010 Your fopen() statement is missing the second parameter. You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php errors in your code will be reported and displayed. You will save a ton of time. Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/#findComment-1128537 Share on other sites More sharing options...
tempguy Posted October 31, 2010 Author Share Posted October 31, 2010 Same exact code was working 20 min ago but i dont know what happened it just stoped working so what should i do to get it work? Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/#findComment-1128544 Share on other sites More sharing options...
revraz Posted October 31, 2010 Share Posted October 31, 2010 http://php.net/manual/en/function.fopen.php You are not specifing the mode. Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/#findComment-1128546 Share on other sites More sharing options...
trq Posted October 31, 2010 Share Posted October 31, 2010 Same exact code was working 20 min ago Not possible. Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/#findComment-1128551 Share on other sites More sharing options...
tempguy Posted October 31, 2010 Author Share Posted October 31, 2010 Hahah I accidentally changed the $data = file("gb.txt"); and didnt realize it. Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/217332-cant-create-a-file-what-is-wrong/#findComment-1128565 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.