Dreamhost and File Get

If you're having problems with your PHP scripts in Dreamhost, it's probably the File Get command.

You'll need to use curl, so create this function:


// function to replace file_get_contents()
function file_get_the_contents($url) {
$ch = curl_init();
$timeout = 10; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}

Then, whenever you see a line that looks something like:

file_get_contents("http://...");

Change file_get_contents to file_get_the_contents.

Please take note that there's an http:// after file_get_contents. If your PHP code does not show the http, then please leave the file_get_contents as-is.

I hope that solves your PHP script problems in Dreamhost.

[ First posted on 04/30/2008 by Manuel Viloria ]




  Previous Entry
  Secondthoughts Index
  Next Entry


Lose Weight Forever


Get In Touch With Manuel Today

Manuel@Viloria.net

Copyright © 1996 - 2008 by Viloria.com All Rights Reserved.





Secondthoughts @ Viloria.com
"We Host at H4P because H4P is affordable,
reliable, and customer-friendly!"
-- Manuel Viloria


  About Manuel Viloria
  Secondthoughts Archives
  Angelhouser
  Viloria.com
  RSS Feed


  Google Reader