I am trying to make my script install a config file with the right settings so the it can be used by anyone. Here is the file that will create the config file:

<?php
$dbhost = $_POST["dbhost"];
$dbuser = $_POST["dbuser"];
$dbpass = $_POST["dbpass"];
$dbname = $_POST["dbname"];
$location = $_POST["location"];

$configfile = "<?php
/**
 * @Blood 08
 * @copyright 2008
 */
//
//Setting Database
//Begin
\$dbhost = '".$dbhost."';
\$dbuser = '".$dbuser."';
\$dbpass = '".$dbpass."';

\$conn = mysql_connect(\$dbhost, \$dbuser, \$dbpass) or die (mysql_errno());

\$dbname = '".$dbname."';
mysql_select_db(\$dbname);
//End
//Setting Database
//

//
//Setting Include Path
//Begin
ini_set(\"include_path\", \".:../:./include:../include\");
//End
//Setting Include Path
//
?>";

$ourFileName = $location."config.inc.php";
$ourFileHandle = fopen($location.'config.inc.php', 'w') or die("Couldn't Create file");
fwrite($ourFileHandle, $configfile);
fclose($ourFileHandle);

header( 'Location: '.$location.'install/install.php?page=dbsetup' ) ;
?>

$location is equal to: $url

$direct = dirname($_SERVER['SCRIPT_NAME']);
$direct2 = dirname($direct);
$url = "http://".$_SERVER['HTTP_HOST'].$direct2."/";

I already have config.inc.php in the correct directory and after I run this script I get no errors, but when I look at config.inc.php there is nothing written in it???

You won't be able to see any errors since you have a redirect to a new page.

Put a die(); before youre redirect while you test so you can see if there are errors.

Also make sure you have error reporting enabled and set to max.

error_reporting(E_ALL);
ini_set('display_errors', '1');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.