Page 3 of 3

Posted: Fri Mar 23, 2007 6:06 pm
by ziggy3000

Code: Select all

$content = '<?php   // single quote not double
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>';// end single quote not double
I used this code

Code: Select all

$content = '<?php
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>';
but i still get

Code: Select all

<?php
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>
in config.php

Posted: Fri Mar 23, 2007 6:07 pm
by tecktalkcm0391
ziggy3000 wrote:

Code: Select all

$content = '<?php   // single quote not double
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>';// end single quote not double
I used this code

Code: Select all

$content = '<?php
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>';
but i still get

Code: Select all

<?php
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>
Do you not comprehend me or the website change the ' and the ' to " and "

Example:

Code: Select all

$text = 'Hello... message here';
// Example 1:
   $message = '$text';
   Echo $message;
   // Outputs
   // $text

// Example 2:
   $message = "$text";
   Echo $message;
   // Outputs
   // Hello... message here

Posted: Fri Mar 23, 2007 6:08 pm
by ziggy3000
oh... i thought it was the other way around... sorry.

Posted: Fri Mar 23, 2007 6:09 pm
by ziggy3000
now i am getting this error

Code: Select all

Parse error: parse error, unexpected T_STRING in C:\Server\Apache\htdocs\Config_maker.php on line 47

Posted: Fri Mar 23, 2007 6:10 pm
by tecktalkcm0391
ziggy3000 wrote:oh... i thought it was the other way around... sorry.
It's ok, just be careful cause one mistake can totally mess up your codes.

Posted: Fri Mar 23, 2007 6:22 pm
by ziggy3000
ziggy3000 wrote:now i am getting this error

Code: Select all

Parse error: parse error, unexpected T_STRING in C:\Server\Apache\htdocs\Config_maker.php on line 47
Can anyone help?

this is the code

Code: Select all

$content = "<?php  //46
define("site_title", "$site_title");  //47
define("db_host", "$db_host");  //48
define("db_user", "$db_user");  //49 
define("db_pass", "$db_pass");  // 50
define("db_name", "$db_name");  //51
?>";

Posted: Fri Mar 23, 2007 6:37 pm
by RobertGonzalez
What are you trying to do with the $content var?

Posted: Fri Mar 23, 2007 6:41 pm
by ziggy3000
Again this is my code. i am trying to write $content to config.php

Code: Select all

//config_maker.php
<?php
<html>
<head>
<title>Config.php Maker</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="write" id="write">
 Site Title
 <input name="site_title" type="text" id="site_title">
 <br>
Host
 <input name="db_host" type="text" id="db_host">
 <br>
 Database User
 <input name="db_user" type="text" id="db_user">
 <br>
 Database Password
 <input name="db_pass" type="password" id="db_pass">
 <br>
 Database Name
 <input name="db_name" type="text" id="db_name">
 <br>
 <input type="submit" name="Submit" value="Submit">
</form>
<?php

if ($_POST['Submit']) {

//Defining Variables
$site_title = $_POST["site_title"];
$db_host = $_POST["db_host"];
$db_user = $_POST["db_user"];
$db_pass = $_POST["db_pass"];
$db_name = $_POST["db_name"]; 

$file_to_write = 'Config.php';

$content = "<?php
define("site_title", "$site_title");
define("db_host", "$db_host");
define("db_user", "$db_user");
define("db_pass", "$db_pass");
define("db_name", "$db_name");
?>";

$fp = fopen($file_to_write, 'w');
fwrite($fp, $content);
fclose($fp);
echo "Success! <br>";
echo $file_to_write;
echo " has been written";
}

?>
<br>
<a href="chmod.php">Chmod Config.php</a><br> //works dont need help on it
<a href="delete.php">Click Here to Delete Config.php</a> //works, dont need help on it
</body>
</html>

Posted: Fri Mar 23, 2007 6:44 pm
by nickvd
I think it may just be time to buy a book...

Code: Select all

$content = '<?php
define("site_title", "' . $site_title . '");
define("db_host", "' . $db_host . '");
define("db_user", "' . $db_user . '");
define("db_pass", "' . $db_pass . '");
define("db_name", "' . $db_name . '");
?>';

Posted: Fri Mar 23, 2007 6:45 pm
by ziggy3000
i'm going to get a big fat book this weekend. :)

Oh and thank you so much, it works! 8)

Posted: Sat Mar 24, 2007 10:20 am
by RobertGonzalez
Ziggy, have a read up on strings in PHP. Your quotes were killing you on this one.