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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
bob2588 Posted October 24, 2009 Author Share Posted October 24, 2009 That Worked Thanks 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.