• Register
Log In
1 vote

Problem :

I have very recently started earning PHP. Now I am facing below error if I try to run the script. Please find the error message as below for your reference.

Warning: file_get_contents() [function.file-get-contents]: https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/satoship/public_html/connect.php on line 22

I have done the required research on this error and now I know this is the server related issue but still I am unaware of the steps those I need to take to fix above server error.

3.2k points

1 Answer

0 votes

Solution :

I had faced this issue in the past. I had also done a lot of research and found solution on it. So to fix my issue I wrote below function and it fixed my issue. You can also use below function to fix your issue.

$phpurl = "http://www.example.org/";
$phpch = curl_init();
curl_setopt ($phpch, CURLOPT_URL, $phpurl);
curl_setopt ($phpch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($phpch, CURLOPT_RETURNTRANSFER, true);
$phpcontents = curl_exec($phpch);
if (curl_errno($phpch)) {
  echo curl_error($phpch);
  echo "\n<br />";
  $phpcontents = '';
} else {

if (!is_string($phpcontents) || !strlen($phpcontents)) {
echo "Failed to get the required phpcontents.";
$phpcontents = '';

echo $phpcontents;

Also you need to edit your php.ini and you need to find allow_url_fopen in it and set it to allow_url_fopen = 1

Hope above solution helps.

5.4k points

Related questions

0 votes
1 answer 149 views
Problem : When I am trying to upload the csv file with zipcode it will convert and save the latitude and logitude. A error is occurring to convert a zipcode to lat,lng. In the localhost its working very fine. But when I am trying to upload it in the live server. I am ... the google api key also. I am unable to add php.ini file. If I try to upload php.ini file then it shows internal server error.
asked Jan 31 jwilliam 3.9k points
0 votes
1 answer 135 views
Problem : Currently I am facing many problems because of below message I have tried everything that I could, but below message is not going away: &ldquo;The secret passphrase in configuration (blowfish_secret) is too short.&rdquo; I am working on Windows, I have already restarted ... to clear the browser history and cookies in my browser but still I am facing the error. How can I fix the error?
asked Feb 24 mphil 2.3k points
0 votes
2 answers 83 views
Problem : I have just upgrade from Magento (form key disabled) to the Now I cannot login to a backend. My error message is 'You did not sign in correctly or your account is temporarily disabled.' I tried to reset my cookie domain, ... are many posts that are concerning magento 2, but far less talking about the magento 1. Does someone with magento 1 had and solved above issue?
asked Jan 18 jwilliam 3.9k points
0 votes
1 answer 40 views
Problem : Facing the AMD-V is disabled in the BIOS (or by the host OS) (VERR_SVM_DISABLED) error message while trying to start the virtual machine using my VM VirtualBox. I am facing this issue on my Windows 7 machine.
asked Jan 14 jwilliam 3.9k points
0 votes
1 answer 63 views
Problem : I am new to MySQL and facing following error message while trying to connect my DB: "Lost connection to MySQL server at 'reading initial communication packet, system error: 0" If I am trying to connect my MySQL DB to the localhost then everything is working as ... ") or die(mysql_error()); Does anyone ever faced such issue? Also please let me know the solution for this issue if possible.
asked Nov 22, 2019 peterlaw 6.9k points