PHP help please

PHP help please

Posted by: matta
Posted on: 2006-11-08 15:38:00

k. I having a huge problem and I never had this before. I did everything just rite and I can't fix it. here's the problem:


Warning: include(.html) [function.include]: failed to open stream: No such file or directory in /home/.ornek/conceptourneys/conceptourneys/index.php on line 167

Warning: include() [function.include]: Failed opening '.html' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/.ornek/conceptourneys/conceptourneys/index.php on line 167

the site is conceptourneys.com

Thanks

Matta

Edited by matta on 11/08/06 06:02 PM (server time).

Re: PHP help please

Posted by: scjessey
Posted on: 2006-11-08 18:40:00

In reply to:

k. I having a huge problem and I never had this before. I did everything just rite and I can't fix it. here's the problem:


First of all, the word is right.

The error message is stating that the file you are trying to include does not exist. I recommend that you copy and paste the include() line from your code here so that we can see what the problem is.

Re: PHP help please

Posted by: anonymous2
Posted on: 2006-11-08 18:52:00

From what you rote, watever is set to point at:

/home/.ornek/conceptourneys/conceptourneys/index.php

should probably point at:

/home/.ornek/conceptourneys/conceptourneys.com/index.php

Defnitly somhtin rong heer.



You are welcome to a refund.-Michael;Comparing 'DH of today' with 'DH of old' does not serve much purpose.-Dallas

Re: PHP help please

Posted by: wholly
Posted on: 2006-11-08 18:54:00

Man, we can be buttheads here. Helpful, but buttheads.

Re: PHP help please

Posted by: anonymous2
Posted on: 2006-11-08 19:10:00

Some buttheads, some good humored; it's a delicate balance.

You are welcome to a refund.-Michael;Comparing 'DH of today' with 'DH of old' does not serve much purpose.-Dallas

Re: PHP help please

Posted by: matta
Posted on: 2006-11-08 19:29:00

<?php include ("$page.html"); ?>

my index.php is in my root/conceptourneys
my .html page are also in there

when I insert the code from my cutephp news it works fine, but not that command.

Matta

P.S. buttheads can be useful though

Edited by matta on 11/08/06 07:33 PM (server time).

Re: PHP help please

Posted by: silkrooster
Posted on: 2006-11-08 20:51:00

The Include states a string and combine 2 strings together and the second string is lacking the $ symbol.
I don't think that was your intentions.
Try something like
<?php include ("$page" . '.html'); ?>
This will append .html to the string page.
Silk


My website

Re: PHP help please

Posted by: matta
Posted on: 2006-11-08 21:06:00

Doesn't work. Same problem.

Re: PHP help please

Posted by: seiler
Posted on: 2006-11-08 22:01:00

You can leave .ornek/ out of the path like this: /home/conceptourneys/conceptourneys

And you did verify that the domain directory is conceptourneys and not conceptourneys.com? It will default to the full domain name, unless you changed it when you added the domain.

The default format would be /home/username/domainname.com.


Anyway... $page is not being assigned a value, as shown in this error:

Warning: include(.html) [function.include]: failed to open stream

I'd add some code to check that $page is being set, and if it's not, assign a default value.

Something like:

if(!isset($page)) {
$page = 'whatever';
}

If $page is pulling from a GET variable, then you'll need to change it to $_GET['page'] instead of $page.

If that's not the problem, then you should post the code where $page is getting assigned a value.

Re: PHP help please

Posted by: schietschijf
Posted on: 2006-11-09 02:54:00

this is just the same you give as solution.
Php searches for variables in strings with double quotes, so "$page.html" is correct resolved to test.html if $page = "test"

Did you check whether the $page variable is correctly filled up?

Re: PHP help please

Posted by: scjessey
Posted on: 2006-11-09 03:21:00

In reply to:

<?php include ("$page.html"); ?>


I recommend a completely different approach. Let me assume that the page you want to include is here:

/home/.ornek/conceptourneys/conceptourneys/page_to_include.html

Instead of using a relative path, try doing it this way:

$page = "page_to_include.html";
include($_SERVER['DOCUMENT_ROOT']."/conceptourneys/$page");

Personally, I prefer to put all my "includes" in a separate folder. All of my include links look like this:

include($_SERVER['DOCUMENT_ROOT']."/includes/whatever.php");

--------
Simon Jessey | Keystone Websites
Save $97 on yearly plans with promo code SCJESSEY97

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 05:58:00

k still not working. do I need to install anything on my dreamhost server or what? this is weird. I know my php and if I don't than I have some resources, but for some reason nothing is working. Any ideas anyone?

Matta

Re: PHP help please

Posted by: anonymous2
Posted on: 2006-11-09 06:42:00

> Any ideas

Edit: 1. Sorry, that was overly obnoxious of me. I reacted to "nothing is working." Obviously, some things are working. Maybe if you described more of your situation, that would help. I still wonder about directory structure, missing files, permissions, etc.

2. Ask smart questions (TM)



You are welcome to a refund.-Michael;Comparing 'DH of today' with 'DH of old' does not serve much purpose.-DallasEdited by anonymous2 on 11/09/06 07:09 AM (server time).

Re: PHP help please

Posted by: seiler
Posted on: 2006-11-09 11:00:00

Did you read my reply?

It's not going to work until you assign a value to $page. The error says you're trying to include(.html). See the whole bunch of nothing where $page should be? ;)

Re: PHP help please

Posted by: kchrist
Posted on: 2006-11-09 11:47:00

I see you're using URLs like this: http://www.conceptourneys.com/index.php?page=specialthanks

Replace $page in your code with $_GET['page']. What you're trying to do will only work with register_globals on. With PHP5, it's off for security reasons.

I would actually recommend a different approach. You shouldn't blindly use user-supplied input. You might start by writing a switch statement (or a series of if-elseif statements) with the values you expect to see, match them against the input you receive as query string arguments, and drop everything else.

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 13:16:00

I will be willing to make a account for some to access it and try there self. Because I tried all the commands you guys are giving me and for some reason they aren't working. If no one replies within the next hour than I'll delete the domain and try it again from there. Thanks for your help you guys

Matta

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 14:21:00

well I deleted the whole domain and started over. I reuploaded everything and now the site isn't showing for some reason. I get this:

Site Temporarily Unavailable
We apologize for the inconvenience. Please contact the webmaster/ tech support immediately to have them rectify this.

error id: "bad_httpd_conf"

Probably cause I have to wait a bit. If not than someone tell me how to fix it. Hopefully this will fix the php problem. If not than I don't know what to do than

thanks

Matta

Websites in Design Process
Matta Productions - (10% done) - http://www.mattaproductions.com

Young Fyre - (50% done)
http://www.youngfyre.com

ConCepTourneys (well humm..having issues but if it wren't than 90% done)
http://www.conceptourneys.com


Re: PHP help please

Posted by: seiler
Posted on: 2006-11-09 14:40:00

Sometimes you can wait it out. Sometimes, just re-saving your domain settings does the trick. When all else fails, just report the error to support and they'll fix it.

The problem is definitely that $page has no value assigned to it. Without seeing more of the code where $page is defined, it's being assumed that the only way it's defined is by variable passed in the URL.

Like I said in my first reply, if you're pulling from a URL, you need to use $_GET['page'] instead of page. If there are several instances of it and you don't want to look through all of the code and replace it, just add this line to the top:

$page = $_GET['page'];

Then, $page will work.

Since the rest of the page, and your site in general, were working, I don't think deleting/re-installing will change anything, as PHP is still the same.

I just went to the site and see it's back up... sorta. The error shows it running under another user and you've gone with the default .com directory name -- just in case you need to change any hard coded references to the path.

include(.html) is still there, showing that $page isn't being defined.

I'm also only getting the bad_http_conf error on the www version, while the site is partially loading for me without the www... but I guess that could be a cache-thing.

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 15:07:00

I inserted the code and still nothing. Add me on aim at matthammond21 or msn matthammond21@hotmail.com

Matta

Re: PHP help please

Posted by: seiler
Posted on: 2006-11-09 17:12:00

I don't have any messenger clients installed, but here's a quick easy test page you could make:

Let's call it test.php

<?php
$page = $_GET['page'];
echo '$page is ' . $page;
?>

Save that as test.php in your web directory.

When you go to conceptourneys.com/test.php, it should print out:

$page is

Now, go to conceptourneys.com/test.php?page=working!

This time it should print out:

$page is working!


At this point, we know that there is no problem grabbing variables from the URL. Of course, this only matters if that's how your script is defining $page.


Now, put a file in your web directory called include.php that contains the text, "Include worked."

Replace the original contents of test.php with this:

<?php
$page = $_GET['page'];
if ($page == 'include.php') {
include("{$_SERVER['DOCUMENT_ROOT']}/$page");
} else {
echo 'Include failed.';
}
?>

Now, go to conceptourneys.com/test.php?page=include.php

That will print out whether or not the include failed or succeeded.

If both of those tests work, PHP is doing its job (I tested them to make sure they worked).

Is there a place in your script where $page is defined, or is it only in the URL?

I'd search the code for every mention of $page. If there's not a line where it's defined ($page = 'something';), and it's only being grabbed from URLs, then you can do two things:

1. Put this at the top of every page where $page will be called from (or in one file that's always included):

$page = $_GET['page'];

2. Do a search & replace for $page, replacing it with $_GET['page']

If there's a config file, or something that you know is included with every single page, you could add the code in step 1 there.

If it still doesn't work... it should at least put out a different error. If "include(.html)" changes to something like "include('/the/path/the_file.html')" -- then you know $page is now being defined, so you would then just need to make sure the file is where it's trying to include it from.


It would probably be a good idea to post the part of the code where $page is being defined, or if it's not defined, at least the first section of code where it's mentioned.

Also, is there a newer version of the script your using? If so, I'd upgrade and see if they've already corrected the problem. I can't picture releasing a script that counted on register_globals being on.

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 18:15:00

THANKS!!! It worked, but you got me lost on one part. Never used this command before. But k. My index.php is my layout. I want it grab my .html files like index.php?page=down or whatever. Or should I make my .html to php? Im trying to make the command grab my .html or whatever.

How about this code (i put this in my index.php to pull my .html files or whatever):

<?php

if(isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "down";
}

include("{$_GET['page']}.html");

?>

It works but if I just type conceptourneys.com/index.php it gives me an error. But if I type conceptourneys.com/index.php?page=down and it works. Did I do it rite?

MattaEdited by matta on 11/09/06 07:09 PM (server time).

Re: PHP help please

Posted by: seiler
Posted on: 2006-11-09 20:31:00

The file extension you use doesn't really matter, unless there's PHP code in it, then it's nice to hide it in a PHP file.

That looks right for pulling the GET variables, and will default to down.html if it's not set.

The include() statement should work as is--if your .html files are in the same directory (conceptourneys.com). If they're in a separate directory, like /includes, you'd have to change it to this:

include("includes/{$_GET['page']}.html");

Or better yet:

include("{$_SERVER['DOCUMENT_ROOT']}/includes/{$_GET['page']}.html");

You could also just put the include in the if statement, like this:

<?php
if (isset($_GET['page'])) {
include("{$_SERVER['DOCUMENT_ROOT']}/{$_GET['page']}.html");
} else {
include("{$_SERVER['DOCUMENT_ROOT']}/down.html");
}
?>

Or, if you do have another directory in the path:

<?php
if (isset($_GET['page'])) {
include("{$_SERVER['DOCUMENT_ROOT']}/includes/{$_GET['page']}.html");
} else {
include("{$_SERVER['DOCUMENT_ROOT']}/includes/down.html");
}
?>

Even better yet, make sure the requested page exists in your directory, to keep people from trying to inject stuff:

<?php
if (isset($_GET['page']) && file_exists("{$_SERVER['DOCUMENT_ROOT']}/includes/{$_GET['page']}.html")) {
include("{$_SERVER['DOCUMENT_ROOT']}/includes/{$_GET['page']}.html");
} else {
include("{$_SERVER['DOCUMENT_ROOT']}/includes/down.html");
}
?>


In reply to:

It works but if I just type conceptourneys.com/index.php it gives me an error. But if I type conceptourneys.com/index.php?page=down and it works. Did I do it rite?


It shouldn't give an error, because no variable should be the same as if it was set to ?page=down. I'd make sure that the files are either in the same directory as index.php, or add the folder they're in to the path.

Re: PHP help please

Posted by: matta
Posted on: 2006-11-09 20:56:00

Thanks a lot. I owe you! It works great. Yeah I might do everything in php or something. Use the include a lot to hide my files. A include in another inlclude than the file. Where do you go for your php resources? It's google.com a lot or teamphp.com. I wanna get a book on it so I can learn more about the new PHP5.

Matta

Matta

Re: PHP help please

Posted by: seiler
Posted on: 2006-11-10 02:47:00

No problem. ;)

PHP.net's manual is the best resource. You can just add function names to the URL and get redirected directly to the function page. Ex: php.net/file_get_contents.

Some vague entries will take you to the main index for a section, like php.net/mysql.

You can also download various versions of the manual here.

Other helpful sites:

Zend (Look under the Developer Zone menu.)
PHP Builder
DigitalPoint PHP Forum

If you're screwing something up, Googling the error message will bring up something useful most of the time.

I've also bought a bunch of PHP books... which I barely read, then sold for a loss on ebay. Things update & change to frequently to commit to a paper book, plus it's easier to use a search box than flip through pages.

Anyway, it's very rare that I need to look beyond PHP.net for help. Bonus: The user comments in the PHP manual can be just as helpful as the official entries--sometimes, more so. I always read through them... and it's also why I generally use the online manual instead of the downloaded version.

Re: PHP help please

Posted by: matta
Posted on: 2006-11-16 19:09:00

Well for some reason I ran into another error. when I put another php script within my index.php like getting someone's ip address or get browser. I get this error:

Parse error: syntax error, unexpected T_LNUMBER, expecting ']' in /home/.ornek/concept/conceptourneys.com/testing.php on line 188

Matta

Tags: mattaserver timeopen streamphp helpphp5inclusionlibusr