jnerotrix Posted December 5, 2008 Share Posted December 5, 2008 My Code Wont Create / Write File Here is The Code it just Displays The die('can't open file'); <?php $myFile = "./ip/' . $ip . '.txt"; $fh = fopen($myfile, 'w') or die("can't open file"); $stringData = "numTimes = 10 \n"; fwrite($fh, $stringData); $stringData = "shorturl = $shorturl \n"; fwrite($fh, $stringData); $stringData = "autoplay = $autoplay \n"; fwrite($fh, $stringData); $stringData = "reloadtime = $reloadtime \n"; fwrite($fh, $stringData); $stringData = "setwidth = $setwidth \n"; fwrite($fh, $stringData); $stringData = "setheight = $setheight \n"; fwrite($fh, $stringData); $stringData = "fullurl = $fullurl \n"; fwrite($fh, $stringData); fclose($fh); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135730-solved-php-code-writecreate-file-wont-write-create/ Share on other sites More sharing options...
premiso Posted December 5, 2008 Share Posted December 5, 2008 Are you sure the file is writeable (chmod 0775) ? Chances are you do not have the permission to open the file. I would remove the die and see what the fatal error shows up. Quote Link to comment https://forums.phpfreaks.com/topic/135730-solved-php-code-writecreate-file-wont-write-create/#findComment-707212 Share on other sites More sharing options...
PFMaBiSmAd Posted December 5, 2008 Share Posted December 5, 2008 Use full php error reporting to get php to tell you why. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/135730-solved-php-code-writecreate-file-wont-write-create/#findComment-707216 Share on other sites More sharing options...
jnerotrix Posted December 5, 2008 Author Share Posted December 5, 2008 it says Notice: Undefined variable: myfile in /www/rack111.com/m/y/t/mytestsite/htdocs/youtube/other.php That The File is Undefined when it is clearly defined as <?php $myFile = "./ip/' . $ip . '.txt"; $fh = fopen($myfile, 'w'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135730-solved-php-code-writecreate-file-wont-write-create/#findComment-707217 Share on other sites More sharing options...
kenrbnsn Posted December 5, 2008 Share Posted December 5, 2008 The variables $myFile and $myfile are not the same. PHP is case sensitive when it comes to variable names. Ken Quote Link to comment https://forums.phpfreaks.com/topic/135730-solved-php-code-writecreate-file-wont-write-create/#findComment-707222 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.