xyn Posted February 12, 2007 Share Posted February 12, 2007 Hi guys, Basically i'm attempting to create an installer for a little system i am creating I'm currently having issues with fwriting the Config file. Basically I don't actually know the way to do it, or if there is an, so if you know of any other way please let me know, otherwise I'm getting the following problems... The Error: /config.php not writable Sorry, but the congif file was not wrote. My code is... <?php //fwrite config chmod("../config.php", 0777); $filename = "/config.php"; $config = ' <?PHP\r\n $host ="'.secure($_POST['host']).'";\r\n $login ="'.secure($_POST['db_user']).'";\r\n $pwd ="'.secure($_POST['db_pass']).'";\r\n $db ="'.secure($_POST['db_name']).'";\r\n $conn = mysql_connect("$host", "$login", "$pwd") or die("SQL Connect Error: ".mysql_error());\r\n mysql_select_db($db, $conn) or die("SQL Database Error: ".mysql_error());\r\n ?> '; if (is_writable($filename)) { if(!$handle = fopen($filename, 'W+')) { echo("config wont open"); exit; } if(fwrite($handle, $config) === FALSE) { echo ("<P align=left>/config.php not writable<BR>Sorry, but the config file was not wrote.</P>"); exit; } fclose($handle); } else { echo ("<P align=left>/config.php not writable<BR>Sorry, but the config file was not wrote.</P>"); exit; } } chmod("../config.php", 0644); ?> Link to comment https://forums.phpfreaks.com/topic/38190-fwrite-problems/ Share on other sites More sharing options...
Balmung-San Posted February 12, 2007 Share Posted February 12, 2007 Is the webserver the owner of the file? If I remember my linux permissions correctly you must be the owner of the file or root to change the permissions of it. As well, since you have the same error message in there for 2 different places, could you change one of them slightly so you know which one it's printing out? Link to comment https://forums.phpfreaks.com/topic/38190-fwrite-problems/#findComment-182827 Share on other sites More sharing options...
xyn Posted February 12, 2007 Author Share Posted February 12, 2007 the error comes around the file not being writable... except, its already on 0777, and thats without the script doing it :s Link to comment https://forums.phpfreaks.com/topic/38190-fwrite-problems/#findComment-182949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.