• 0

HELP! Problem writting in a file PHP


Question

i have a problem, i'm trying to write in a file but it looks that there is a problem. i have a function that writes in a file the config and then connects to the db to create the tables

function installation_proc() {

$host = $_SESSION["host"];

$dbuser = $_SESSION["dbnewusername"];

$dbpass = $_SESSION["dbnewpassword"];

$dbname = $_SESSION["dbnewname"];

$string = '<?php

$host = "'.$host.'";

$dbuser = "'.$dbuser.'";

$dbpass = "'.$dbpass.'";

$dbname = "'.$dbname.'";

$lim = "6";

$template = "home.php";

?>';

$fp = fopen("config.php", "w");

fwrite($fp, $string);

fclose($fp);

$fp = fopen("../news/config.php", "w");

fwrite($fp, $string);

fclose($fp);

$connection = mysql_connect($host, $dbuser, $dbpassword)

or die("Unable to connect to MySQL");

mysql_select_db($dbname, $connection) or die("Unable to select DB!");

but is not working. i copy the same code in a test.php file and when i run it i show that wrote on the file. can any one help me pls?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
What error are you getting?

What context are you using the function in?

im not getting any error. it just continues to execute the queries for the creation of tables and after the installation finish i open the config.php and is empty

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.