Can someone help me?
I have a script that I’ve put together from several different scripts. They all access a config.php file to connect to database, but one of them requires a couple of paths to certain file locations. I made a install.php file that creates table and also creates the config.php file I want to incorporate the file locations into the config.php file so there is only one config file for all scripts. It works till I get to the section that I need to add paths at.
Starting at
fwrite($fp, "\t\$changepassword =\"security/chgpwd.php";\n");
fwrite($fp, "\t\$login = "http://" . $SERVER['HTTP_HOST'] . "/security/login.php";\n");
fwrite($fp, "\t\$logout = "http://" . $
SERVER['HTTP_HOST'] . "/security/logout.php";\n");
The first fwrite is something I tried “didn’t work” the others are copied right from the original config.php file they came from and they don’t work

			fwrite($fp, "<?php\n");
			fwrite($fp, "\t\$dbServer=\"$dbServer\";\n");
			fwrite($fp, "\t\$dbUsername=\"$dbUsername\";\n");
			fwrite($fp, "\t\$dbPassword=\"$dbPassword\";\n");
			fwrite($fp, "\t\$dbDatabase=\"$dbDatabase\";\n");
			fwrite($fp, "\t\$changepassword =\"security/chgpwd.php";\n");
			fwrite($fp, "\t\$login = "http://" . $_SERVER['HTTP_HOST'] . "/security/login.php";\n");
			fwrite($fp, "\t\$logout = "http://" . $_SERVER['HTTP_HOST'] . "/security/logout.php";\n");
			fwrite($fp, "?>");
			fclose($fp);

    take a look at the syntax highlighting of your code... it's not escaped properly.

    try

                fwrite($fp, "<?php\n"); 
                fwrite($fp, "\t\$dbServer=\"\$dbServer\";\n"); 
                fwrite($fp, "\t\$dbUsername=\"$dbUsername\";\n"); 
                fwrite($fp, "\t\$dbPassword=\"$dbPassword\";\n"); 
                fwrite($fp, "\t\$dbDatabase=\"$dbDatabase\";\n"); 
                fwrite($fp, "\t\$changepassword =\"security/chgpwd.php\";\n"); 
                fwrite($fp, "\t\$login = \"http://" . $_SERVER['HTTP_HOST'] . "/security/login.php\";\n"); 
                fwrite($fp, "\t\$logout = \"http://" . $_SERVER['HTTP_HOST'] . "/security/logout.php\";\n"); 
                fwrite($fp, "?>"); 
                fclose($fp);
    

    (edit: whoa.... why does this site take away some of my backslashes?)

      Parse error: syntax error, unexpected T_VARIABLE in /home/public_html/stration/setup.php on line 94

      fwrite($fp, "<?phpn"); 
                  fwrite($fp, "t$dbServer="\$dbServer\";\n");

        Maybe writing it like this would be less confusing:

        <?php
        
        fwrite($fp, <<<EOP
        <?php
        	\$dbServer="$dbServer";
        	\$dbUsername="$dbUsername";
        	\$dbPassword="$dbPassword";
        	\$dbDatabase="$dbDatabase";
        	\$changepassword ="security/chgpwd.php";
        	\$login = "http://{$_SERVER['HTTP_HOST']}/security/login.php";
        	\$logout = "http://{$_SERVER['HTTP_HOST']}/security/logout.php";
        ?>
        EOP
        );
        ?>
        

          I got this to work,now I want to add some more to it but I get an error
          Parse error: syntax error, unexpected T_VAR in /home/public_html/Admin/config.php on line 15
          **************Is where I add the other stuff Im thinking its the var that is causing the problem, but I cant figure out what it should be and still have the file that needs that part to still be able to read it right

          	$dbServer="localhost";
          	$dbUsername="me";
          	$dbPassword="pw";
          	$dbDatabase="pw_dir";
          	$resultpage ="Authenticate.php";
          	$admin ="admin/index.php";
          	$success ="members/index.php";
          	$failure ="failed.php";
          	$login ="http://{$_SERVER['HTTP_HOST']}/Signup/login.php";
          	$logout ="http://{$_SERVER['HTTP_HOST']}/Signup/logout.php";
          	$changepassword ="http://{$_SERVER['HTTP_HOST']}/Signup/chgpwd.php";
          	$confirm ="http://{$_SERVER['HTTP_HOST']}/Signup/confirm.php";
          	$adminemail ="email@email.com";
          	var $HOST = "localhost";**********
          	var $USERNAME = "me";
          	var $PASSWORD = "pw";
          	var $dbDatabase= "pw_dir";	

          The portion of the file that uses this is

          class auth{
          
          var $HOST = "localhost";
          var $USERNAME = "me";
          var $PASSWORD = "pw";
          var $dbDatabase= "pw_dir";
          
          // AUTHENTICATE

            Why did you suddenly start writing "var" there? That was unexpected.

              I&#8217;m trying to combine all the config files into one. The current script is referencing 3 different ones and I think it would be better to have just one. I have a install script that builds the DB Tables, insert data, write the config file and everything. I don&#8217;t see any reason to reference 3 files if it don&#8217;t need to.

                I was wrong earlier the lines with this info
                http://{$_SERVER['HTTP_HOST']}/Signup/confirm.php

                Changes when the config.php file is greated to this
                http://{$_SERVER[\'HTTP_HOST\']}/Signup/confirm.php

                Which errors out
                Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/public_html/Admin/config.php on line 10

                Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/public_html/Admin/config.php on line 10

                I really thought I was getting some where after 2 days of fighting this stuff
                PLEASE HELP

                  Did you read the error message? Whatever "greated" means, the error message is telling you the backslash shouldn't be there.

                    I use a form on the setup.php you enter connection data to connect to DB, enter all the other stuff I have in code above and it writes the config.php file that the script uses to connect to Db. Parts of the other scripts use other data from the config.php file as well.
                    I enter this http://{$SERVER['HTTP_HOST']}/Signup/confirm.php the config.php gets written and then if you look at the file it has this http://{$SERVER[\'HTTP_HOST\']}/Signup/confirm.php which error out
                    My question is why does it add the \ and how do I make it write to the file with out adding the \

                      Write a Reply...