Jump to content

file_get_contents - help needed


bulmer

Recommended Posts

Hello everyone. First post and am very much a learner..

I have been modifying a Shipping Module, for my Zen-cart website, on a Local Development setup on my PC. I have it working perfectly on my local setup but once I upload it to my website it won't work! (Pride deflating..)

The PHP versions, on both setups are the same. I'm really stuck with this one and would really appreciate anyones help.

The problem may be with urlencode, but I'm not sure where.I only have to insert the 'postcode' and 'city' variables into the URL parameters, the rest are just hardcoded. I had to urlencode the 'city' variable before insertion, due to the spaces between many town names. They insist on a space being made after the city ($foo) argument also, which is why i included '%20'.

// First get the destination postcode and city name
$topcode = $order->delivery['postcode'];
        $zoo = $order->delivery['city'];
        $foo = urlencode($zoo);
if ( $topcode == '' ){
// Something is wrong, we didn't find any dest zip
$this->quotes['error'] = MODULE_SHIPPING_XXX_NO_POSTCODE_FOUND;
        return $this->quotes;
}
//SENDS A REQUEST TO THE API FOR THE XML FILE
$url = "http://www.xxxxxxx.org/Magic94Scripts/mgrqispi94.dll?appname=FW&PRGNAME=FastLocatorRecord&ARGUMENTS=-A1,-ANTH,-A$foo%20,-A$topcode,-A10,-N1";
$xml = file_get_contents($url) ;

//TRANSFORMS THE RETURNED XML INTO AN OBJECT
$rec = simplexml_load_string($xml);

Link to comment
https://forums.phpfreaks.com/topic/220611-file_get_contents-help-needed/
Share on other sites

My log shows this error:

"file_get_contents(http://www.xxxxxxx.org/Magic94Scripts/mgrqispi94.dll?appname=FW&PRGNAME=FastLocatorRecord&ARGUMENTS=-A1,-ANTH,-AHogarth+Range%20,-A2469,-A10,-N1) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: no suitable wrapper could be found in /home/zzzz/public_html/includes/modules/shipping/xxxxxxx.php on line 80"

line 80 is :

$xml = file_get_contents($url) ;

The $url variables contents have been urlencoded before the request was sent? How can I avoid this happening? Is it a setting in my websites PHP config?

Cheers.

 

 

Is there another error message in the same vicinity that looks like this, per chance?

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /Applications/MAMP/htdocs/test.php on line 2

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.