Jump to content

[SOLVED] php 5 equivalent to php 4 file_get_contents


ballhogjoni

Recommended Posts

Does anyone know what the equivalent to php 4 file_get_contents for php 5?

 

I am getting this error:

Warning: file_get_contents(https://www1.xxxxxx.com/partners/links/cards/details.asp?id=xxxxx&tempid=xxxxxxx) [function.file-get-contents]: failed to open stream: No such file or directory in /home/xxxx/public_html/xxxxxxxx/reviews.php on line 20

 

line 20

$sContents = file_get_contents(https://www1.xxxxxx.com/partners/links/cards/details.asp?id=xxxxx&tempid=xxxxxxx);

file_get_contents is available for both PHP4 and 5. You can try other file reading methods, such as file, but perhaps you have provided an invalid link or maybe its because you're using a secure connection.

it should be

 

$sContents = file_get_contents('https://www1.xxxxxx.com/partners/links/cards/details.asp?id=xxxxx&tempid=xxxxxxx');

you need the quote things

 

If the parameter is passed in as a variable then it won't have or need the quotes around it. Placing single quotes around a variable will cause the variable to not be passed. The quotes aren't necessary in this instance.

The CODE posted as being line 20 in the first post generates a syntax error because it does not have any quotes. We can only assume that someone would post the actual syntax being used so as to not waste time solving a problem with quotes that has nothing to do with the real problem mentioned in the error message.

 

Under the latest version of php5, the following occurred on my Window's based development system -

 

If the openssl extension is not enabled, you get a Notice error: Unable to find the wrapper "https", followed by a Warning error:  ... failed to open stream: No error in...

 

If openssl is enabled and the URL does not exist, you get a Warning error: ...  failed to open stream: A connection attempt failed because the connected party did not properly respond ...

 

If openssl is enabled but allow_url_fopen (spelled correctly?) is not enabled, then you get two Warning errors: ... URL file-access is disabled in the server configuration ... and ... failed to open stream: no suitable wrapper could be found in ...

 

The error message in the first post implies that a local file system path/file name is actually being used in the code and we are all just wasting our time because irrelevant information was provided.

Which php version is the posted error occurring on? php5 on your development system or php4 on your live server?

 

Also, is error_reporting set to E_ALL or is it doing something stupid like turning off Notice messages?

I appreciate the comments. I took off the s in https and it worked fine. It is posting for php 5.2.6

 

No i have e_all set. So i was getting both errors:

 

Unable to find the wrapper "https"

 

URL file-access is disabled

 

Also good point on the quotes.

 

Its fixed now, so thanks.

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.