Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default [Help] Using Php To Write Php To A File!

    Ive got a problem, i have made a code to write some data to a .php file, but when it writes to the file, the data.php file only contains '<? ?>' in it. This is the part of the code that writes to the file.
    PHP Code:
    $write2file = fopen("data.php", "w"); 
    fwrite($write2file,"<?php");
    fwrite(
    $write2file,"echo \"$Data\";");
    fwrite($write2file,"?>;");
    fclose($write2file);
    echo 
    "Done!";
    Lets set the stage on fire, and hollywood will be jealous.

  2. #2
    Join Date
    Aug 2005
    Location
    Tunbridge Wells, Kent
    Posts
    5,063
    Tokens
    1,624

    Latest Awards:

    Default

    did you put <?php CODE ?> in ?
    Never argue with an idiot, he'll drag you down to his level, and beat you with experience.

    Quote Originally Posted by Recursion
    *oh trust me
    *I would NEVER go ATi
    And 15 mins later...
    Sapphire ATI Radeon HD 5850 1024MB GDDR5 PCI-Express Graphics Card £195.73 1 £195.73
    *ordered.

  3. #3
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by Tom743 View Post
    Ive got a problem, i have made a code to write some data to a .php file, but when it writes to the file, the data.php file only contains '<? ?>' in it. This is the part of the code that writes to the file.
    PHP Code:
    $write2file = fopen("data.php", "w"); 
    fwrite($write2file,"<?php");
    fwrite(
    $write2file,"echo \"$Data\";");
    fwrite($write2file,"?>;");
    fclose($write2file);
    echo 
    "Done!";
    PHP Code:
    <?php
    $text 
    = <<<HTML
    <?php
    echo "
    {$data}";
    ?>
    HTML;
    $file fopen("data.php""w"); 
    fwrite($file$text);
    fclose($file);
    echo 
    "Done!";
    ?>

  4. #4
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    What is with the whole <<<HTML thing?

    Never seen that before.

    Just make it

    PHP Code:
    <?php
    if ($_GET ["action"] == "update") {
        
    $stuff $_POST ["stuff"];
        
    $filename $_POST ["filename"];
        
    $file = @fopen $filename ".php""w+" );
        @
    fwrite $file$stuff );
        @
    fclose $file );
        echo 
    "Done";
        exit ();
    }
    ?>
    <form name="thing" action="?action=update" method="post">
    Filename (exclude .php): <br />
    <input type="text" name="filename"><br /><br />

    Contents:<br />
    <textarea name="stuff"></textarea>
    </form>
    Should do it.

  5. #5
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    What ever your trying to do, it looks horrible - Explain further and I might be able to help.
    Hi, names James. I am a web developer.

  6. #6
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by Navicat View Post
    What is with the whole <<<HTML thing?

    Never seen that before.

    Just make it

    PHP Code:
    <?php
    if ($_GET ["action"] == "update") {
        
    $stuff $_POST ["stuff"];
        
    $filename $_POST ["filename"];
        
    $file = @fopen $filename ".php""w+" );
        @
    fwrite $file$stuff );
        @
    fclose $file );
        echo 
    "Done";
        exit ();
    }
    ?>
    <form name="thing" action="?action=update" method="post">
    Filename (exclude .php): <br />
    <input type="text" name="filename"><br /><br />

    Contents:<br />
    <textarea name="stuff"></textarea>
    </form>
    Should do it.
    Basically, if you want to do a load of HTML with ' and "'s and cba to do \, you just use
    $string = <<<HTML
    HTML
    "
    /
    '
    alaldkasd
    HTML; // MUST HAVE NO INDENTS;
    echo $string;

  7. #7
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    Quote Originally Posted by DriftPanzy View Post
    What ever your trying to do, it looks horrible - Explain further and I might be able to help.
    What does, my code?

    Quote Originally Posted by Blob View Post
    Basically, if you want to do a load of HTML with ' and "'s and cba to do \, you just use
    $string = <<<HTML
    HTML
    "
    /
    '
    alaldkasd
    HTML; // MUST HAVE NO INDENTS;
    echo $string;
    Oh, never done that before. I just use the opposite ' or " of what is used more.

  8. #8
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by DriftPanzy View Post
    What ever your trying to do, it looks horrible - Explain further and I might be able to help.
    Well there is a page called submit.php, there is a form on that page, and it has a textbox with the name data and a submit button.

    When you click submit i need it to write this code to a .php file

    <?php
    echo "$Data"
    ?>

    Lets set the stage on fire, and hollywood will be jealous.

  9. #9
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I did some code to write to a file, http://www.habboxforum.com/showthread.php?t=463370 - that should give you an outline.
    Hi, names James. I am a web developer.

Posting Permissions

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