Farmbot Posted January 18, 2013 Share Posted January 18, 2013 I have 7 lines of code that quit working after years of smooth sailing, allegedly because my servers updated to PHP 5.2 It let flash pass variables to the PHP and then write them to a text file. <?php $myFile = "picks.txt"; $fh = fopen($myFile, 'w+') or die("can't open file"); echo "Your picks have been submited"; fwrite($fh, $newcontent); fclose($fh); ?> I've been looking online for days trying to figure out what might need to be updated, but I had no idea there were multiple versions of PHP until this happened so, I'm at a loss on how to even research this. Any ideas? And thanks for reading this far! Quote Link to comment https://forums.phpfreaks.com/topic/273333-write-to-file-quit-working-php52/ Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 Register globals. Quote Link to comment https://forums.phpfreaks.com/topic/273333-write-to-file-quit-working-php52/#findComment-1406773 Share on other sites More sharing options...
requinix Posted January 18, 2013 Share Posted January 18, 2013 ...has been turned off in the new version you have, which is exactly how it should be. $newcontent = (isset($_POST["newcontent"]) ? (string)$_POST["newcontent"] : ""); Quote Link to comment https://forums.phpfreaks.com/topic/273333-write-to-file-quit-working-php52/#findComment-1406777 Share on other sites More sharing options...
Farmbot Posted January 18, 2013 Author Share Posted January 18, 2013 Hot diggity! Thanks Jessica for getting it started, and hail to requinix, because I was currently researching "register globals" and don't know how long it would have taken me to get to the code that you provided! It works again! Quote Link to comment https://forums.phpfreaks.com/topic/273333-write-to-file-quit-working-php52/#findComment-1406785 Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 I'm lazy(er) when on the mobile site. Thanks requinix Quote Link to comment https://forums.phpfreaks.com/topic/273333-write-to-file-quit-working-php52/#findComment-1406799 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.