Help with PHP Include

Ok apparently dreamhost has disabled using includes the way i’ve always used them, so my whole site ( is down and im having a hard time fixing the tangled web of includes throughout my page. can anyone help me out?

how do you ususally include? what include method isn’t working?

I usually require/include like so:

require ($_SERVER[‘DOCUMENT_ROOT’].’/code/’);
or of course
include ($_SERVER[‘DOCUMENT_ROOT’].’/code/’);

Dreamhost allows php includes in general, but has disabled the use of allow_url_fopen for security reasons.

If your site uses this function, you can (and should!) rewrite the code to use curl to fetch the offsite content, and make sure local files are included using paths instead of urls.

There is a lot of discussion on this in these forums, and on the Dreamhost wiki. If you have an example of specific code that is now broken and would like for us to look at it, please include that code in a post - otherwise, any help that we might offer would only be guessing :wink:

From looking at your site, the problem appears to be one of properly addressing your mysql server. If you are trying to “include” your connection info, it appears that it is being “read”, but that the info is not correct for your server (per the error message). This makes me think your problem is not with the include, but with your connection settings.


<? include $_SERVER['DOCUMENT_ROOT']."/photoshop/tutorials/skycaptain/tuthits.php" ?>

that usually includes my script to add to the view count of that particular tutorial, the code for that script below

<?php $count_my_page = ("views.txt"); $hits = file($count_my_page); $fp = fopen($count_my_page , "r"); print $hits[0]; fclose($fp); ?>

(i know flat files may not be the best but im still recoding my site)

and the error i get is

Warning: file(views.txt) [function.file]: failed to open stream: No such file or directory in /home/.paxil/ehsehm/ on line 3

Appreciate all the help i get

I have had to use curl instead of url_fopen myself. kind of a pain but it works.

nvm i got it, thank you all. im sure ill run into more than a few problems in the near future lol

Maybe you could offer a bit of help with my fopen dilemma???

Here is my code:

$preview_xml = “\n”;
$preview_xml.= “”.htmlspecialchars(stripslashes($values[“title”]))."\n";
$preview_xml.= “”.htmlspecialchars(stripslashes($values[“description”]))."\n";
$preview_xml.= “”.htmlspecialchars(stripslashes($events[“url”]."/".$values[“folder”]))."\n";
$preview_xml.= “”.htmlspecialchars(extract_location($values[“country”],$values[“state”],$values[“city”]))."\n";
$preview_xml.= “”;

$f = fopen($events[“path”]."/tmp".$tempfolder."/preview.xml",“w”);

Since the allow_url_fopen is disabled, I am getting the following error:
Warning: file(): URL file-access is disabled in the server configuration in …

The code is used in a preview button function, which opens a _blank target, and I have verified that all variables are being passed correctly.

I’m not sure how to convert the fopen code to cURL in order to see if it allows me to pop-up a preview window. Is this enough information to evaluate?


Well, it’s a start, but if I’m reading your code correctly (and I might not be, 'cause it’s late here :wink: ), I believe that the error is generated as a result of the following code:

$f = fopen($events[“path”]."/tmp".$tempfolder."/preview.xml",“w”);

and, from that, I suspect the problem lies in the code that assigns $events, which you did not include. Basically, it looks like $events[“path”]."/tmp".$tempfolder." evaluates to a (partial) url, and the code that sets that up is not here.

You may not need to “cURL” it at all, if you can modify the appropriate strings/variables to produce a path on the server rather than an “http://” url. I’d start looking at the problem from that standpoint, and using that approach, before trying to “cURL” the whole thing, but that’s just me. There are others far more expert at PHP than me on the forum, and maybe one of them will have a better suggestion.

It also helps greatly if you provide the whole, rather than a truncated, error message - without the whole error message, we are kinda “debugging” in the dark. :wink: