bob2588 Posted October 24, 2009 Share Posted October 24, 2009 i am try to make a php file called db_2.php i can make the files but i am have a hard time getting the varables in to the file the files should loook like this <?php $host = "localhost"; $user = "user"; $pass = "pass"; $db_name = "bob_ad"; //database connection $link = mysql_connect($host, $user, $pass); mysql_select_db($db_name); but the code put this in there ='localhost'; ='user'; and last is the php file that does the writing <?php $makedb = "db_2.php"; $fh = fopen($makedb, 'w') or die("can't open file"); $stringData = "$host='localhost';\n"; fwrite($fh, $stringData); $stringData = "$user='user';\n"; fwrite($fh, $stringData); fclose($fh); ?> does any have any idea's thanks bob Link to comment https://forums.phpfreaks.com/topic/178869-solved-php-write/ Share on other sites More sharing options...
Alex Posted October 24, 2009 Share Posted October 24, 2009 Your problem is that it's trying to actually parse $host as a variable, which has no value. So instead you should be using single quotes which don't parse variables. eg $stringData = '$host="localhost";' . "\n"; You could also make things easier on yourself and use file_put_contents() which acts the same way as fopen(), fwrite() and fclose(), just making it simpler for you. Link to comment https://forums.phpfreaks.com/topic/178869-solved-php-write/#findComment-943648 Share on other sites More sharing options...
bob2588 Posted October 24, 2009 Author Share Posted October 24, 2009 That Worked Thanks Link to comment https://forums.phpfreaks.com/topic/178869-solved-php-write/#findComment-943658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.