ballhogjoni Posted December 6, 2008 Share Posted December 6, 2008 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); Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2008 Share Posted December 6, 2008 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. Quote Link to comment Share on other sites More sharing options...
balistic Posted December 6, 2008 Share Posted December 6, 2008 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 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2008 Share Posted December 6, 2008 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. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted December 6, 2008 Share Posted December 6, 2008 But he should still use quotes just to avoid pissing off people like me who read his code "IT'S NOT A CONSTANT, USE FRIGGEN QUOTES!" how many times I have yelled that I do not know. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted December 6, 2008 Share Posted December 6, 2008 Hm, yeah I read it wrong. Yeah you should be using quotes. My bad. I thought you were passing in a variable. Quote Link to comment Share on other sites More sharing options...
balistic Posted December 6, 2008 Share Posted December 6, 2008 yep, i just tried it. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 6, 2008 Share Posted December 6, 2008 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. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 6, 2008 Share Posted December 6, 2008 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? Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted December 6, 2008 Author Share Posted December 6, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.