Twentyoneth Posted March 16, 2006 Share Posted March 16, 2006 I have been trying to write multiple files at the same time and cannot seem to get it to write more than the first. It will write the first and go to write the second file, but then it stops and leaves the file blank. Im pulling variables from a form and having it write that value to a file, there are five total, but no matter what I do it will not write more than the first, help?The "Change Colors" statement is the one with the five files that need to be written.Here is where you can see the code...[a href=\"http://nicotinejunkie.cv.vc/code.txt\" target=\"_blank\"]the code[/a] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 16, 2006 Share Posted March 16, 2006 You have a number of lines that look similar to:[code]<?php $fileclose($two); ?>[/code]They probably should be coded as:[code]<?php fclose($two); ?>[/code]I'm surprised that you didn't get sytax errors with this code.Ken Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 16, 2006 Author Share Posted March 16, 2006 Wow, I can't believe that I missed that! But, even with those changes, there is no luck. And my host has errors turned off. but, I will put them back on and edit this post if there are any errors...**EDIT: still no luck, there are no erros...** Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 16, 2006 Author Share Posted March 16, 2006 This is my most recent code, but same problem:[a href=\"http://nicotinejunkie.cv.vc/code.txt\" target=\"_blank\"]Code[/a] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 16, 2006 Share Posted March 16, 2006 You still have syntax errors in this code. You have [code]<?php $fclose($two); ?>[/code] instead of [code]<?php fclose($two); ?>[/code].Can you post the code to the script that drives this code?Ken Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 16, 2006 Author Share Posted March 16, 2006 [!--quoteo(post=355690:date=Mar 16 2006, 05:51 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 16 2006, 05:51 PM) [snapback]355690[/snapback][/div][div class=\'quotemain\'][!--quotec--]You still have syntax errors in this code. You have [code]<?php $fclose($two); ?>[/code] instead of [code]<?php fclose($two); ?>[/code].Can you post the code to the script that drives this code?Ken[/quote]I have fixed the $fclose to fclose, but still no luck, the two codes are here:[a href=\"http://nicotinejunkie.cv.vc/code.txt\" target=\"_blank\"]Code 1[/a][a href=\"http://nicotinejunkie.cv.vc/code2.txt\" target=\"_blank\"]Code 2[/a] Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 17, 2006 Share Posted March 17, 2006 Never ever hide errors. That is a very big mistake. Fix your errors because if all you do is hide them sure no one sees errors, but the code does not give the desired results either. Hiding notices is fine, but never hide errors. Even if your code still seems to work fine, when you post it to another server which still reports errors your users are going to see errors. Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 17, 2006 Author Share Posted March 17, 2006 [!--quoteo(post=355735:date=Mar 16 2006, 08:14 PM:name=txmedic03)--][div class=\'quotetop\']QUOTE(txmedic03 @ Mar 16 2006, 08:14 PM) [snapback]355735[/snapback][/div][div class=\'quotemain\'][!--quotec--]Never ever hide errors. That is a very big mistake. Fix your errors because if all you do is hide them sure no one sees errors, but the code does not give the desired results either. Hiding notices is fine, but never hide errors. Even if your code still seems to work fine, when you post it to another server which still reports errors your users are going to see errors.[/quote]My host has errors turned off, in my code I have them turned with the ini_set, but no errors show... Quote Link to comment Share on other sites More sharing options...
txmedic03 Posted March 17, 2006 Share Posted March 17, 2006 I would talk to my host about this or find a better host. They are not the sharpest oranges in the toaster. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted March 17, 2006 Share Posted March 17, 2006 You had a lot of redundant code...I think I eliminated most of it.You also still had a few $ infront of fwrite and fclose fuctions. I've used servers before that will not show any syntax errors at all, even if error reporting is on and turned to E_ALL. It's irritating, to say the least.Hope this helps, make sure to remove the spaces in all the file functions...the forum software doesn't like those functions.[code]<?php$logfile = "log/log.txt";$log = file_get_contents($logfile);$date = date('l, F d, Y (g:ia)');$ip = $_SERVER['REMOTE_ADDR'];$user = $_POST['user'];$pass = $_POST['pass'];$action = $_POST['action'];$filename = "usercomments/usercomments.php";$filenametwo = "usercomments/lock.php";$filetopcolor = "usercomments/topcolor.php";$writetopcolor = $_POST['topbg'];$filebottomcolor = "usercomments/bottomcolor.php";$writebottomcolor = $_POST['bottombg'];$filetopfont = "usercomments/topfont.php";$writetopfont = $_POST['topfont'];$filebottomfont = "usercomments/bottomfont.php";$writebottomfont = $_POST['bottomfont'];$fileborder = "usercomments/border.php";$writeborder = $_POST['border'];$write = "There are no comments.<br>";$writetwo = "1";$writethree = "0";ini_set("display_errors", "1");ini_set("error_reporting", "E_ALL");if ($_POST[user] == "user") { if ($_POST[pass] == "pass") { if ($action == "Clear Comments") { $f ileopen = f open($filename, 'w') or die("Can't open file."); f write($fileopen, $write); $message = "The comments have been cleared.<br><br>"; $logwrite = ("Comments cleared by: " . $ip . " || " . $date); f close($fileopen); } else if ($action == "Lock Comments") { $fileopen = f open($filenametwo, 'w') or die("Can't open file."); f write($fileopen, $writetwo); $message = "The comments have been locked. <img src=images/clock2.png></img><br><br>"; $logwrite = ("Comments locked by: " . $ip . " || " . $date); f close($fileopen); } else if ($action == "Unlock Comments") { $fileopen = f open($filenametwo, 'w') or die("Can't open file."); f write($fileopen, $writethree); $message = "The comments have been unlocked. <img src=images/clock.png></img><br><br>"; $logwrite = ("Comments unlocked by: " . $ip . " || " . $date); f close($fileopen); } elseif ($action == "Change Colors") { if ($writetopfont == null) { $message .= "No changes to $filetopfont<br>"; $numberone++; } else { $fileopen = f open($filetopfont, 'w') or die("Cant open Top Font."); f write($fileopen, $writetopfont); $message .= "$filetopfont has been changed to $writetopfont<br>"; f close($fileopen); $numberone++; } if ($writetopcolor == null) { $message .= "No changes to $filetopcolor<br>"; $numbertwo++; } else { $two = f open($filetopcolor, 'w') or die("Cant open Top Color."); f write($two, $writetopcolor); $message .= "$filetopcolor has been changed to $writetopcolor<br>"; f close($two); $numbertwo++; } if ($writebottomfont == null) { $message .= "No changes to $filebottomfont<br>"; $numberthree++; } else { $three = f open($filebottomfont, 'w') or die("Cant open Bottom Font."); f write($three, $writebottomfont); $message .= "$filebottomfont has been changed to $writebottomfont<br>"; f close($three); $numberthree++; } if ($writebottomcolor == null) { $message .= "No changes to $filebottomcolor<br>"; $numberfour++; } else { $four = f open($filebottomcolor, 'w') or die("Cant open Bottom Color."); f write($four, $writebottomcolor); $message .= "$filebottomcolor has been changed to $writebottomcolor<br>"; f close($four); $numberfour++; } if ($writeborder == null) { $message .= "No changes to $fileborder<br>"; $numberfive++; } else { $five = f open($fileborder, 'w') or die("Cant open Border."); f write($five, $writeborder); $message .= "$fileborder has been changed to $writeborder<br>"; close($five); $numberfive++; } } } else { echo "Invalid Password."; }} else { echo "Invalid Username.";}//log write codeif ($logwrite != "") { $logwrite = "<table border=0 width=100%><tr><td vAlign=top align=left>-</td><td vAlign=top align=left>" . $logwrite . "</td></tr></table>"; if ($log == "No log entries.") { $two = f open($logfile, 'w') or die("Cant open log."); f write($two, $logwrite); f close($two); } else { $two = f open($logfile, 'w') or die("Cant open log."); f write($two, $logwrite); f close($two); }}echo $message . "<a href=ap.php>Back to Admin Panel</a>";?>[/code] Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted March 17, 2006 Author Share Posted March 17, 2006 My code works fine once you pull all of the "$" out of the file commands. Thanks for your help! I guess I was so frustrated that I couldnt get it to work, that I skipped over that all together, twice! Thank you so so much. I have been trying to get that to work for over a week....and phpfreaks wouldnt let me post >_< ...Thanks alot guys! Quote Link to comment 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.