implode file failing but url is correct

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pedalpete
    New Member
    • Oct 2007
    • 109

    #1

    implode file failing but url is correct

    I've been working on this for hours, and i keep getting the same error.

    I am trying to grab the content from a file on my own server.
    The page I request has a variable passed, and it wasn't working with include so i decided to try implode file.

    The error includes the file that php says can't be found, but if I copy that url from the error, and then past it into the address bar, the page comes up no problem.

    Anybody know why this isn't working?
    My code is here. error below
    Code:
    $id=base64_encode($id);
    // echo $id.'<br/>';
    
    	$url="http://localhost/mapickl/processes/update.php?id=$id";
    echo $url.'<br/>';
    	$bid= implode("", file($url));
    the error is
    file(http://localhost/mapickl/processes/u...UuY29tL2pld2Vs) [<a href='function. file'>function. file</a>]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
    any ideas on this?
    Should i be able to use 'include' with parameters? and is it faster than my using implode?

    thanks,
    Pete
    Last edited by pbmods; Nov 26 '08, 10:39 PM. Reason: Fixed error text.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    What exactly are you trying to do there? Do a HTTP request on the localhost?
    Why not simply create a function that does what this page is meant to do and use that instead?

    In any case, if you stick to your current method, rather than using file() and implode(), try using the file_get_conten ts() function. See if that changes anything.

    Comment

    • pedalpete
      New Member
      • Oct 2007
      • 109

      #3
      file_get_conten ts

      Hi Atli,

      Thanks for the recommendation, unfortunately that is working either.

      I can understand why it would seem strange, but I use that function on a few different pages, so I was trying to share it, and I haven't learned how to use public functions(??) (basically, i don't know how to share a function across pages, though I know it is possible.

      I guess it's time for me to get my learn on ;)

      though it is strange that this doesn't work.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by pedalpete
        Hi Atli,

        Thanks for the recommendation, unfortunately that is working either.

        I can understand why it would seem strange, but I use that function on a few different pages, so I was trying to share it, and I haven't learned how to use public functions(??) (basically, i don't know how to share a function across pages, though I know it is possible.

        I guess it's time for me to get my learn on ;)

        though it is strange that this doesn't work.
        Do you get the same error as before?

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          does it also fail when you use an absolute path (something like "/var/www/mapickl/processes/update.php" (example), server root see phpinfo()) ?

          regards

          Comment

          • pedalpete
            New Member
            • Oct 2007
            • 109

            #6
            got it to work with an include

            strangely, even full path failed. Not sure why.

            I ended up moving the function into a seperate file and including that file in the page.
            That worked perfectly, and is probably what I should have been doing originally.

            It's like PHP new I was being lazy and wouldn't let me be;)

            Comment

            Working...