#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    359
    Rep Power
    10

    Fopen Invalid argument error. What does it mean?


    Hi,

    I am receiving the following error and don't understand why.

    Is there something wrong with the url that I am using in the fopen.

    Warning: fopen(misc/netshopsaffiliates.php?table=hammocks) [function.fopen]: failed to open stream: Invalid argument in ________\_________\________\delimiter\pipe.php on line 3
    First few lines of the script include:

    PHP Code:
    $durl "misc/netshopsaffiliates.php?table=hammocks";

    $sourced fopen("$durl""r"); 
    Please help, thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2004
    Posts
    791
    Rep Power
    237
    "misc/netshopsaffiliates.php?table=hammocks" is not a valid file name/path. You can use fopen() on "misc/netshopsaffiliates.php" though (if the path is correct).

    Edit: Could you explain please what you are trying to do ?
    Last edited by SKDevelopment; November 28th, 2006 at 11:54 AM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Aug 2004
    Posts
    1,795
    Rep Power
    84
    if you want to pass in parameters to another php script like that then you're going to have to fopen it by its full URL(with http:// and all that). This is the slow method that you really only do if you have to execute something on a remote server. If it is on the same server, it is just superfluous overhead. You can probably rework the program to work with an include or require.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    359
    Rep Power
    10
    Originally Posted by SKDevelopment
    "misc/netshopsaffiliates.php?table=hammocks" is not a valid file name/path. You can use fopen() on "misc/netshopsaffiliates.php" though (if the path is correct).

    Edit: Could you explain please what you are trying to do ?
    I have a script that is located within the root of my server so it can't really be viewed by the web browser. With this script, it then pulls datafeeds from a remotely hosted database. Each $table variable is a different datafeed. I have to open each one after each other and do things with the information and then insert into my database.

    The things is it will be much easier if I could either do it the way that I am trying or if it will work some how with http:// as I have hundreds of different urls and I can't make an extra script just for this merchant's products.

    I will now work on something.

    Thanks for your help.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Aug 2004
    Posts
    1,795
    Rep Power
    84
    you can do [PHPNET="define"]define[/PHPNET]("table","hammocks") and [PHPNET="require"]require[/PHPNET] or [PHPNET="include"]include[/PHPNET] a file above the webroot. Then in that file, you have the constant table defined and you can do something based on that.

    Comments on this post

    • SKDevelopment agrees : Yes, I would also use require or include
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    359
    Rep Power
    10
    I have sorted it out now. I have just moved the php file above the root and am now using a full url that includes http://

    It now works just fine.

    Thanks!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Aug 2004
    Posts
    1,795
    Rep Power
    84
    no it doesn't
    if the file is above the webroot, it is inaccessible through the http:// scheme. No matter how hard you try, you aint going to get it. If you mean it is in another web accessible directory then yes it will work but it adds unneeded overhead that could easily be eliminated by a simple include. Also this eliminates the security that you would get if the script was above the webroot. Anybody on the net can now hit the netshopsaffiliates.php file.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    359
    Rep Power
    10
    Thanks. I have now used the include as described and put it back into an none accessible directory.

IMN logo majestic logo threadwatch logo seochat tools logo