tags:

views:

42

answers:

3

Hi there,

Trying to get a text value either "yes" or "no" from an aspx page via my php product page.

from here..

after code= i need to insert the product model number $products_model

example.. http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code=RN311014

replace RN311014 with $products_model and then echo back the text result

hope someone can help..

thanks scott

i tryed this within my orginal code

<?php $contents = file_get_contents("http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&amp;code={$products_model}", NULL, NULL, 0, 3); echo $contents;

Blockquote

+1  A: 

try using

$value=file_get_contents('http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&amp;code=&lt;code&gt;');

echo $value;

you can also consider using "PHP Curl"

Sourabh
Scott
Did you even read Sourabh's answer?
Emil Vikström
yes and tested it..but no luck
Scott
A: 

The problem is that it is not just text that is returned. There is HTML there as well (view source). You need to pull the first line out of the file that is returned as well. For example:

$contents = file_get_contents("http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&amp;code={$products_model}", NULL, NULL, 0, 3);

echo $contents;
Joseph
thanks, il try now
Scott
would it need to be in a seperate php page? i tryed it within my existing code, but the page failed to display.. i inserted this<?php $contents = file_get_contents("http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3decho $contents;?>
Scott
place `error_reporting(E_ALL); ini_set('error_reporting', E_ALL); ini_set('display_startup_errors','1'); ini_set('display_errors','1');` at the beginning of your page, and let me know what the errors say.
Joseph
@Scott: I have tried it on two seperate servers. Both servers have `allow_url_fopen` set to `On`. However, one gives an error as though it were off, and the other works fine. You will need to go with the cURL method `digiwombat` mentions.
Joseph
A: 

The other two posted solutions will only work if allow_url_fopen has been enabled, which it likely hasn't.

http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

Lots of hosts and PHP builds won't have it enabled for various reasons.

You can either change it in your php.ini or use a CURL request, which would really be the better way about it, ASSUMING CURL is enabled on your PHP install.

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&amp;code=&lt;CODE GOES HERE LADIES>');
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
$contents = curl_exec ($ch);
curl_close ($ch);

echo $contents;

That should work... probably. It'll get you close enough anyway. Haha.

digiwombat
@digiwombat: Actually, it is enabled on my servers, one of which works and one of which doesn't. Still trying to figure out what would is causing it to not work. Am guessing firewall, but who knows.
Joseph