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:

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

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

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

\$dbname = '".$dbname."';
//Setting Database

//Setting Include Path
ini_set(\"include_path\", \".:../:./include:../include\");
//Setting Include Path

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

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.

ini_set('display_errors', '1');
This article has been dead for over six months. Start a new discussion instead.