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 3 of 3
  1. #1
    Banned
    Join Date
    Jul 2002
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with file

    I try to show my file, but it is not working. My PHP is 4.2

    My phpeditor says
    Notice: Undefined index: fp in c:\itohideo\ito1.php on line 14

    Notice: Undefined variable: filename in c:\itohideo\ito1.php on line 18

    Warning: fopen("", "r") - No error in c:\itohideo\ito1.php on line 18
    not open your file

    Here is my code


    <html>
    <body>
    <p>set up your file</p>
    <form method="post" action="ito1.php">
    <input type="text" size="80" name="filename"><br>
    <br>
    <input type="submit" name="submit" value="send">
    <input type="reset" name="reset" value="reset">
    </form>
    <br>


    <?php
    $fp=$_POST["fp"];
    if($_POST["submit"]!="")
    {

    $fp= fopen($filename,"r");
    if(!$fp){

    print("not open your file");
    exit;

    }

    print("<TT>\n");

    while($buf=fgets($fp,8192)){

    $buf=htmlspecialchars($buf);
    $buf=ereg_replace("\n","<br>\n",$buf);
    $buf=ereg_replace(" ","$nbsp;",$buf);
    print("$buf\n");


    }
    print("<TT>\n");
    fclose($fp);

    }

    ?>
    </body>
    </html>

    Please fix my codes
    Thank you

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    U.S. (Wish Japan though)
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yuor missing a } in your code....

    [CODE]
    <?php
    $fp=$_POST["fp"];
    if($_POST["submit"]!="")
    {

    $fp= fopen($filename,"r");
    if(!$fp){

    print("not open your file");
    exit;
    }
    }

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also note:

    Notice: Undefined variable: filename in c:\itohideo\ito1.php on line 18 ------------------ is

    $buf=ereg_replace(" ","$nbsp;",$buf);

    Perhaps &amp;nbsp; would work better.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

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