Activity Stream
48,167 MEMBERS
62698 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1.     
    #1
    Member

    Default How can i create a PHP file via php?

    FIXED:
    This is how i did it.
    PHP Code: 
    public function createdatabase($host,$username,$password,$dbname)
            {
                $File = "../include/database.php"; 
                 $Handle = fopen($File, 'w');
                 $Data = "
    <?php
                
    \$MYSQL_HOST '".$host."';
                \
    $MYSQL_USERNAME '".$username."';
                \
    $MYSQL_PASSWORD '".$password."';
                \
    $MYSQL_DATABASE '".$dbname."';
                try {
                    \
    $dbh = new PDO('mysql:host='.\$MYSQL_HOST.';dbname='.\$MYSQL_DATABASE,\$MYSQL_USERNAME,\$MYSQL_PASSWORD);
                } catch(
    PDOException \$e){
                    
                    echo \
    $e->getMessage();
                }
    ?>
                 "; 
                fwrite($Handle, $Data); 
                 fclose($Handle); 
                 return "file created";
            }
    regards,
    Jordan
    xifyhosting Reviewed by xifyhosting on . How can i create a PHP file via php? FIXED: This is how i did it. public function createdatabase($host,$username,$password,$dbname) { $File = "../include/database.php"; $Handle = fopen($File, 'w'); $Data = " <?php \$MYSQL_HOST = '".$host."'; Rating: 5

  2.   Sponsored Links

  3.     
    #2
    You can call me G
    in $Data use single quotes instead of double and escape things accordingly. Should work fine then



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  4.     
    #3
    Member
    The thing is it's not set as i want it to import as it's seen i want $ to be written in as $


    Fixed:

    /$ did the trick

  5.     
    #4
    Respected Member
    You used the double quotes instead of single quote in the data expression
    $Data = "
    This will always try to find and replace the $ and other special characters.

    The single quote will not do this. It will take everything as written.
    $Data = '

  6.     
    #5
    Member
    Thats what i wanted i needed the $ to show as $ in the text file.... so i had to use /$ this is sorted now

  7.     
    #6
    Member
    Website's:
    epicimagehost.com
    I always use single quotes. Prevents shit like this from happening and makes more sense when looked at.

  8.     
    #7
    Member
    That wasn't the trouble. do you read what i put? i wanted to insert the $ symbol into the test file. NOT what it was worth

  9.     
    #8
    Member
    PHP Code: 
    <?php
    class db{

    function 
    createdatabase($host,$username,$password,$dbname
            { 
                
    $File "../include/database.php";  
                 
    $Handle fopen($File'w'); 
                 
    $Data 

                \$MYSQL_HOST = '"
    .$host."'; 
                \$MYSQL_USERNAME = '"
    .$username."'; 
                \$MYSQL_PASSWORD = '"
    .$password."'; 
                \$MYSQL_DATABASE = '"
    .$dbname."'; 
                try { 
                    \$dbh = new PDO('mysql:host='.\$MYSQL_HOST.';dbname='.\$MYSQL_DATABASE,\$MYSQL_USERNAME,\$MYSQL_PASSWORD); 
                } catch(PDOException \$e){ 
                     
                    echo \$e->getMessage(); 
                } 
                          "
    ;  
                
    fwrite($Handle$Data);  
                 
    fclose($Handle);  
                 return 
    "file created"
            }
            
            }
            
    $db = new db();
            
    $db->createdatabase('localho','root','test','');
    Try that.

  10.     
    #9
    Member
    why do no1 read what i put. It's sorted all i did was add \$

  11.     
    #10
    Member
    We're trying to help you fool. If you don't want help don't bitch when someone tries. Logout and don't come back.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto create txt file in each folder
    By Ruriko in forum Technical Help Desk Support
    Replies: 9
    Last Post: 18th Oct 2012, 02:41 PM
  2. Need Help Create File Hosting site like Rapidgator.net
    By kamalepatel in forum General Discussion
    Replies: 10
    Last Post: 30th Sep 2012, 11:54 PM
  3. How to: Create friendly URLs with your .httaccess File!
    By Raptile in forum Tutorials and Guides
    Replies: 5
    Last Post: 18th May 2012, 04:53 AM
  4. how to create same file with different website url in filename
    By tamildragon in forum Technical Help Desk Support
    Replies: 3
    Last Post: 26th Nov 2010, 05:13 PM
  5. create multiple copies of a file
    By techdaemon in forum Technical Help Desk Support
    Replies: 1
    Last Post: 10th Nov 2010, 02:17 AM

Tags for this Thread

BE SOCIAL