Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    write a content to file

    hi

    i want to write a content in $text into the file. For that i wrote the below code .But i run that code i got the following errors.How i avoid that errors and write the whole content in $text into the file.plz help me

    PHP Code:
    <?php
    $handle 
    fopen("myfile.php"'w+');

    if(
    $handle)
    {
    $text="<?php include('ClassName.class');$myclass = &new ClassName; echo $myclass->myfunction1(); ?>";
        if(!
    fwrite($handle,$text))
            die(
    "couldn't write to file.");

        echo 
    "success writing to file";
    }

    ?>

    errors : Notice: Undefined variable: myclass in F:\Facebook\furniture11\DataMining\public_html\admin\files.php on line 6

    Notice: Undefined variable: myclass in F:\Facebook\furniture11\DataMining\public_html\admin\files.php on line 6
    success writing to file

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    This is when a syntax highlighting editor comes in handy - vim shows me this:

    See the problem? You need to either escape your special characters (like $ and ->) or you need to use a different kind of quote (single quotes). Try this:



    PHP Code:
    <?php
    $handle 
    fopen("myfile.php"'w+');
    if(
    $handle) {
            
    $text='<?php include("ClassName.class");$myclass = &new ClassName; echo $myclass->myfunction1(); ?>';
            if(!
    fwrite($handle,$text))
            die(
    "couldn't write to file.");
            echo 
    "success writing to file";
    }
    ?>
    Last edited by derzok; 08-06-2008 at 04:38 PM.
    zok@zoklet:~$ whereis zok
    zok: http://zoklet.net | http://zoklet.net/otg | /derzok/at/gmail/dot/com


  •  

    Posting Permissions

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