Hi, I have an index.php and curl (and file_get_contents) can retrieve the content from a remote file.

but for pages like index.php?action=detail&id= or index.php/action::detail/id::
curl (and file_get_contents) are not pulling the content and stay just blank (no error message)

What might be the reason?

I am on FreeBSD/Apache2.2/PHP5.3

    The reason might be a problem with your code. Seeing as how you haven't shown that to us, that's about all I can say.

      The code is:

      <?php
      $ch = curl_init();
      $timeout = 5; // set to zero for no timeout
      curl_setopt ($ch, CURLOPT_URL, 'http://www.mydomaindandfilehere');
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      curl_setopt ($ch, CURLOPT_USERAGENT, 'mine');
      $file_contents = curl_exec($ch);
      curl_close($ch);

      // display file
      echo $file_contents;
      ?>

        4 days later

        Man, posters these days sure don't try very hard.

        Martib, your code that you posted makes no reference whatsoever to index.php or any query string parameters.

          Dear sneakyimp why would I need a reference to index.php or any query string parameters to retrieve a remote file?

            martib;11039249 wrote:

            Dear sneakyimp why would I need a reference to index.php or any query string parameters to retrieve a remote file?

            Because you wrote

            martib;11039023 wrote:

            I have an index.php and curl (and file_get_contents) can retrieve the content from a remote file.

            but for pages like index.php?action=detail&id= or index.php/action::detail/id::
            curl (and file_get_contents) are not pulling the content and stay just blank (no error message)

            … which tells us that
            1. requesting index.php results in curl getting contents and your script sending output in its response
            2. requesting index.php with a query string results in a blank page and curl fetching nothing.

            Which means that it might be an idea to investigate what the differences between a request for index.php and index.php?action=detail&id=

            Either way you should always check if curl succeeds or not - and this goes for any other actions that may fail. [man]curl_errno[/man] to check for success, [man]curl_error[/man] to get human readable information.

            I also recommend that you upgrade to php 5.5.10

              Hi johanafm, I am not requesting for index.php. I am requesting within a index.php for a remote file.

              I have an index.php and curl retrieves the content from a remote file.
              In the index.php echo curl_errno($ch); and echo curl_error($ch); return '0'

              But in index.php?action=detail&id= curl is not retrieving the content from this remote file nor an error.

              Currently I am at the point it might have to do with Apache config (<File Match ...)

                martib, forgive me, but you are not explaining your problem well. Maybe try typing it out more clearly?

                  Thank you, let me try:
                  I think the problem comes from how my software parses templates:

                  I have a hand-coded php-document stored on hardrive:
                  http:// www. sjn. to/index2.php

                  I have a php-document generated by templates:
                  http:// www. sjn. to/index1.php

                  and a php-document generated by templates and query string:
                  http:// www. sjn. to/index1.php/action::detail/id::1361350907

                  The first two work fine.

                    Write a Reply...