moviedrome Posted May 1, 2008 Share Posted May 1, 2008 Hi, I wonder if someone can help me with a file-get-contents problem, is there a way around the filename too long error? If not, can someone suggest a better way I can get that xml file into an array? Warning: file_get_contents(https%3A%2F%2Fusers.buy.at%2Fmgt%2Faffiliates%2Fcommission.php%3FEMAIL%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26EPASSWORD%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26ID%3Dxxxxxxxxxxxxxxxxxx%26DATEFROM%3D2008-04-01%26DATETO%3D2008-05-01%26ORDERBY%3Dtrans_date_time%26ORDERDIRECTION%3DASC%26PAGE%3Dall%26FORMAT%3DXML) [function.file-get-contents]: failed to open stream: File name too long in /home/fjnet/public_html/buyat.php on line 59 Thanks in advance Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 anyone? Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 I'm getting no errors, using PHP 5.2.2: <?php echo file_get_contents(urldecode('https%3A%2F%2Fusers.buy.at%2Fmgt%2Faffiliates%2Fcommission.php%3FEMAIL%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26EPASSWORD%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26ID%3Dxxxxxxxxxxxxxxxxxx%26DATEFROM%3D2008-04-01%26DATETO%3D2008-05-01%26ORDERBY%3Dtrans_date_time%26ORDERDIRECTION%3DASC%26PAGE%3Dall%26FORMAT%3DXML')); ?> Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 Also tested on PHP 4.4.7, no errors. But if you want to read it into an array, try file(). Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 i'm using PHP version 4.4.7 but it still keeps telling me the url is too long. Really confused. Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 sorry for double post, i've tried file() as well and i get File name too long in /home/fjnet/public_html/buyat.php on line 59 Link to comment Share on other sites More sharing options...
conker87 Posted May 2, 2008 Share Posted May 2, 2008 Are you placing the url into quotes? Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 my code is: $xml = "https://users.buy.at/mgt/affiliates/commission.php?EMAIL=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&EPASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&ID=xxxxxxxxxxxxxxxxxx&DATEFROM=20{$startdate}&DATETO=20{$enddate}&ORDERBY=trans_date_time&ORDERDIRECTION=ASC&PAGE=all&FORMAT=XML"; return file(urlencode($xml)); print_r($xml); Thanks Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 Oh, you shouldn't urlencode the URL. That breaks it entirely (encoding slashes too). Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 Ok, I've got rid of the urlencode and I now get No such file or directory in /home/fjnet/public_html/buyat.php on line 59 But the link works when i paste it into my browser so i'm not entirely sure what the problem is. Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 Is the code you've showed around line 59 in the file? Maybe the problem lies elsewhere. Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 sorry line 59 is return file($xml); Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 Sounds weird. Be sure that your $startdate and $enddate variables exist and are in the right format for the URL. If you can view the file in your browser, you should be able to read it with PHP too. Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 yep the variables are fine, the xml file opens fine in the browser using the link stored in $xml - i'm at a total loss. Link to comment Share on other sites More sharing options...
discomatt Posted May 2, 2008 Share Posted May 2, 2008 A password passed the URL scares me. Link to comment Share on other sites More sharing options...
moviedrome Posted May 2, 2008 Author Share Posted May 2, 2008 it's encoded Link to comment Share on other sites More sharing options...
discomatt Posted May 2, 2008 Share Posted May 2, 2008 Congrats. It's still set as a referring URI in most web browsers. And that's just icing on the cake. Link to comment Share on other sites More sharing options...
thebadbad Posted May 2, 2008 Share Posted May 2, 2008 I agree that it's generally not a good idea. Only if it's processed strictly through PHP. Link to comment Share on other sites More sharing options...
s4surbhi2218 Posted December 29, 2012 Share Posted December 29, 2012 Is this issue solved?? i am facing the same problem. Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 29, 2012 Share Posted December 29, 2012 Yes. It was solved about 41/2 years ago, from the looks of it. Link to comment Share on other sites More sharing options...
Recommended Posts