WordPress and File Get-Contents

Yes, I don’t know PHP, so I’m sure that’s the first problem. heh… I’m trying to use a simple PHP script to pull in some content from another site of mine, and I’ve learned that Dreamhost prevents this command, and recommends using Curl (whatever that is!).

So I did that, but everytime I add the line of code, and update my template, I get an error that says:

Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

And when I remove the code, or add anything OTHER than this code, it works fine. So every time I add the code, it’s a prob. Here’s the code I’m using, as recommended via Dreamhost:

<?php $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, 'http://www.example.com'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); // display file echo $file_contents; ?>

Weird. Any help?

Let’s first try to increase timeout time

$timeout = 30;

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here

I get the same error when I incorporate PHP code in my Geeklog site’s Static Pages. Dunno what the problem is, so I stopped doing it. I ended up manually adding it into the database via phpMyAdmin. Maybe someone knows why this happens.


If the site you are accessing is on the same DreamHost account (just a different domain), you do not need to use cURL. You can use file_get_contents() with an absolute (relative from root) path:

$data = file_get_contents("/home/username/domainfolder/path/to/file.php");si-blog
Max discount on any plan with promocode SCJESSEYTOTAL

That could be a handy workaround, but cURL seems to be necessary for my grab of:

/gallery/ is a PHP-level rewrite to /gallery2/, and I’m not sure how well the file_get_contents will handle the PHP flags.