SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Create PHP file in code

    Hi,

    Is there a way to create and save a PHP file using code? I would like to create a database connection file on the fly when building the database, so would want to create a file called dbconnect.php, fill it with the database connection details such as 'username' etc from my script

    the final format I would want is

    <?php

    $dbhostname = "localhost";
    $dbdatabase = "MY VARIABLE HERE";
    $dbusername = "private";
    $dbpassword = "private";
    $fgconnection = mysql_pconnect($dbhostname, $dbusername, $dbpassword) or die(mysql_error());
    @mysql_select_db($dbdatabase) or die("Database error (error 1)");

    ?>

    and then save this as a regular PHP file.

    Any help much appreciated!

    Thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi grandad,

    Have a look at this page, you'll find some examples and how to.

    Cheers,
    Pepe


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •