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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.