post some code? and please, only the relevant stuff!

    i am getting a sucess on the fopen, so it's kind of confusing why the fread wouldn't work. the url format is required by the xml feed.

      geez, nothing like using one variable name for everything!

      try using urlencode() instead of htmlspecialchars() - the first is used for converting strings to use as urls, the latter for converting strings to output as html

        Tried that on my way to htmlspecialchars. Gives this result.
        htmlspecialchars fopen returns sucess, doesn't that mean it worked?

        http%3A%2F%2Fdg.travelnow.com%2Fexternal%2Fxmlinterface.jsp%3Fcid%3D66847%26xml%3D%3CServiceRequest+method%3D%27getAllRegions%27%3E
        Warning: fopen("http%3A%2F%2Fdg.travelnow.com%2Fexternal%2Fxmlinterface.jsp%3Fcid%3D66847%26xml%3D%3CServiceRequest+method%3D%27getAllRegions%27%3E", "r") - No such file or directory in travel.php on line 12

        Warning: fread(): supplied argument is not a valid File-Handle resource in travel.php on line 14

          yeah that's more like it - use urlencode

          i think it may be that the setting allow_url_fopen is disabled in your php.ini - this says whether or not a fopen can take a url as it's filename, not just a local file.

          set it in your php.ini, or if you can't then use ini_set

            no, like this

            ini_set("allow_url_fopen", "1");

              No such file or directory:

              ini_set("allow_url_fopen", "1");
              $file = urlencode("http://dg.travelnow.com/external/xmlinterface.jsp?cid=66847&xml=<ServiceRequest method='getAllRegions'>");
              echo $file;
              $file = fopen($file, "r");
              echo $file;
              $file = fread($file, 4096);
              echo $file;
              exit;

              http%3A%2F%2Fdg.travelnow.com%2Fexternal%2Fxmlinterface.jsp%3Fcid%3D66847%26xml%3D%3CServiceRequest+method%3D%27getAllRegions%27%3E
              Warning: fopen("http%3A%2F%2Fdg.travelnow.com%2Fexternal%2Fxmlinterface.jsp%3Fcid%3D66847%26xml%3D%3CServiceRequest+method%3D%27getAllRegions%27%3E", "r") - No such file or directory in travel.php on line 13

              Warning: fread(): supplied argument is not a valid File-Handle resource in travel.php on line 15

                ok mate got it working!

                <?php 
                ini_set("allow_url_fopen", "1"); 
                $file = "http://dg.travelnow.com/external/xmlinterface.jsp?cid=66847&xml=<ServiceRequest&20method='getAllRegions'>"; 
                echo $file; 
                $file = fopen($file, "r"); 
                echo $file; 
                $file = fread($file, 4096); 
                echo $file; 
                exit;
                ?>
                

                first i removed the urlencode altogether
                i got a HTTP/400 Bad Request.
                then i noticed a space in the url which was possibly terminating the string early, so i replaced this with %20 (a urlencoded space)

                and tada! it works. don't know why that happened

                should work on yours too

                adam

                  if you wanted to strip spaces automatically without using urlencode, you could do like this

                  $file = "http://blahblah";
                  $file = ereg_replace(" ", "%20", $file);

                    you are my hero!!! stupid spaces. cheers.

                      no worries! don't forget to mark thread resolved tho (link below)

                        Write a Reply...