fopen problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Banks

    #1

    fopen problem

    I'm using the following code to check if a file exists on the server. If not
    it should do one thing but if it does exist it should do something else.
    This seems to be working except when the file doesn't exist - It echos the
    message to say the file doesn't exist but also outputs the following error:

    Can anyone help please?


    THE ERROR
    _______________ _______________ _______________ _______
    Warning: fopen("images/villas/extra/259.jpg", "r") - No such file or
    directory in /home/zionhill/public_html/proof/villaparade/villa.php on line
    652
    The error is then followed by "Could Not Open File" so I know it is
    partially working

    THE CODE
    ---------------------------------------------------------------------
    if (!$file=fopen(" images/villas/extra/259.jpg","r")){
    echo ("Could Not Open File");
    } else {
    echo ("The file exists")
    }


  • CountScubula

    #2
    Re: fopen problem

    "Andrew Banks" <banksy@nospamb lueyonder.co.uk > wrote in message
    news:BR9Lb.9649 $vc2.107367514@ news-text.cableinet. net...[color=blue]
    > I'm using the following code to check if a file exists on the server. If[/color]
    not[color=blue]
    > it should do one thing but if it does exist it should do something else.
    > This seems to be working except when the file doesn't exist - It echos the
    > message to say the file doesn't exist but also outputs the following[/color]
    error:[color=blue]
    >
    > Can anyone help please?
    >
    >
    > THE ERROR
    > _______________ _______________ _______________ _______
    > Warning: fopen("images/villas/extra/259.jpg", "r") - No such file or
    > directory in /home/zionhill/public_html/proof/villaparade/villa.php on[/color]
    line[color=blue]
    > 652
    > The error is then followed by "Could Not Open File" so I know it is
    > partially working
    >
    > THE CODE
    > ---------------------------------------------------------------------
    > if (!$file=fopen(" images/villas/extra/259.jpg","r")){
    > echo ("Could Not Open File");
    > } else {
    > echo ("The file exists")
    > }
    >
    >[/color]

    Ok, this one it too simple,

    file_exists()


    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools



    Comment

    • Andrew Banks

      #3
      Re: fopen problem

      Ignore me!

      I've just found out about file_exist!!


      Comment

      • CountScubula

        #4
        Re: fopen problem

        "Andrew Banks" <banksy@nospamb lueyonder.co.uk > wrote in message
        news:NiaLb.9678 $KO1.107061261@ news-text.cableinet. net...[color=blue]
        > Ignore me!
        >
        > I've just found out about file_exist!!
        >[/color]


        It happens to every one :)


        Generaly, if you take the last two word from a sentace, verb/noun that is a
        PHP command.
        EX:
        I want to check if a FILE EXIST
        I want to CREATE IMAGE

        just kiddin around...

        --
        Mike Bradley
        http://www.gzentools.com -- free online php tools


        Comment

        Working...