iyeru42 Posted August 8, 2008 Share Posted August 8, 2008 PHP gives the error... $fh = fopen("../includes/dbinfo.inc.php", "w"); if ($fh==false) { die("unable to create ../includes/dbinfo.inc.php. Make sure the includes directory within the forum root dir is CHMOD to 0777."); } else { $strWriteData = "<?php\n$aDBInfo['type'] = '".$aDBInfo['type']."';\n$aDBInfo['address'] = '".$aDBInfo['address']."';\n$aDBInfo['username'] = '".$aDBInfo['username']."';\n$aDBInfo['password'] = '".$aDBInfo['password']."';\n$aDBInfo['database'] = '".$aDBInfo['database']."';\n$aDBInfo['email'] = '".$aDBInfo['email']."';\n?>"; fwrite($fh, $strWriteData); fclose($fh); } How do I make it so I can still write this? (I need the line breaks in the destination file, so I cannot remove the \ns, and I cannot remove the variables that are inside the strings nor the beginning and ending <?php and ?>) Link to comment Share on other sites More sharing options...
Jesdisciple Posted August 8, 2008 Share Posted August 8, 2008 Change it to this and see if it helps. (BTW, this should be faster and easier to read than the above.) $strWriteData = "<?php\n\$aDBInfo['type'] = '{$aDBInfo['type']}';\n\$aDBInfo['address'] = '{$aDBInfo['address']}';\n\$aDBInfo['username'] = '{$aDBInfo['username']}';\n\$aDBInfo['password'] = '{$aDBInfo['password']}';\n\$aDBInfo['database'] = '{$aDBInfo['database']}';\n\$aDBInfo['email'] = '{$aDBInfo['email']}';\n?>"; I escaped the $s and used string parsing rather than concatenation.You might also be interested in heredocs. Link to comment Share on other sites More sharing options...
iyeru42 Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks man, it works now :3 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.