big-dog1965 Posted March 15, 2009 Share Posted March 15, 2009 Can someone show me why this is adding \ to the data that is writen to a config.php file from my setup.php file. What I have is a setup file that is ran from the browser. I use a form to enter data such as DB connect data and then some other paths and such for parts of other script to use for file locatios. I enter http://{$_SERVER['HTTP_HOST']}App/Signup/login.php and when the file is written it adds \ to the line above to the written config.php file like this $dbServer="localhost"; $dbUsername="ton1"; $dbPassword="123456789"; $dbDatabase="ton1_App"; $resultpage ="Authenticate.php"; $admin ="admin/index.php"; $success ="members/index.php"; $failure ="failed.php"; $login ="http://{$_SERVER[\'HTTP_HOST\']}App/Signup/login.php"; $logout ="http://{$_SERVER[\'HTTP_HOST\']}App/Signup101/logout.php"; $changepassword ="http://{$_SERVER[\'HTTP_HOST\']}App/Signup/chgpwd.php"; $confirm ="http://{$_SERVER[\'HTTP_HOST\']}App/Signup/confirm.php"; $adminemail ="admin@email.com"; which creates errors like this for all the line that have http://{$_SERVER['HTTP_HOST']} in them Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/public_html/App/config.php on line 10 Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/public_html/App/config.php on line 10 Here the connect stuff in the setup.php file // connect to the database $dbServer=$HTTP_POST_VARS['dbServer']; $dbUsername=$HTTP_POST_VARS['dbUsername']; $dbPassword=$HTTP_POST_VARS['dbPassword']; $dbDatabase=$HTTP_POST_VARS['dbDatabase']; $resultpage=$HTTP_POST_VARS['resultpage']; $admin=$HTTP_POST_VARS['admin']; $success=$HTTP_POST_VARS['success']; $failure=$HTTP_POST_VARS['failure']; $login=$HTTP_POST_VARS['login']; $logout=$HTTP_POST_VARS['logout']; $changepassword=$HTTP_POST_VARS['changepassword']; $confirm=$HTTP_POST_VARS['confirm']; $adminemail=$HTTP_POST_VARS['adminemail']; $noDB=0; if(!@mysql_connect($dbServer, $dbUsername, $dbPassword)){ $noDB=1; }elseif(!@mysql_select_db($dbDatabase)){ if(!@mysql_query("create database `$dbDatabase`")){ $noDB=2; }else{ if(!@mysql_select_db($dbDatabase)){ $noDB=2; Here the write code // if connection is successful, save parameters into config.php if(!$fp=@fopen("./config.php", "w")){ echo $divFormat."<div style=\"color: red;\">".$Translation["couldnt save config"]."</div></div><br>"; echo $backHome; exit; }else{ 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\$resultpage =\"$resultpage\";\n"); fwrite($fp, "\t\$admin =\"$admin\";\n"); fwrite($fp, "\t\$success =\"$success\";\n"); fwrite($fp, "\t\$failure =\"$failure\";\n"); fwrite($fp, "\t\$login =\"$login\";\n"); fwrite($fp, "\t\$logout =\"$logout\";\n"); fwrite($fp, "\t\$changepassword =\"$changepassword\";\n"); fwrite($fp, "\t\$confirm =\"$confirm\";\n"); fwrite($fp, "\t\$adminemail =\"$adminemail\";\n"); fwrite($fp, "?>"); fclose($fp); When the setup.php is ran from the browser I have a form I enter data into to be written. If manualy change the config.php file by removing the \ around [\'HTTP_HOST\']} it seems to work fine 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.