 |
 |
PHP Problem...
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2002
Location: England | San Francisco
Status:
Offline
|
|
I am having an error on my site (hejog.net). I am building a site which gathers my blog from /blog/index.php - I've used a php include like so -
<?php include ("/blog/index.php"); ?>
but it cannot find the file...
Dont suppose anyone knows whats wrong, I've never really used php
|
|
we don't have time to stop for gas
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
PHP's include system doesn't use relative URLs; you need to tell it where the file is on disk. You can make PHP understand absolute URLs in the include function, but I don't recommend it; the potential security issues are more trouble than it's worth.
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2002
Location: England | San Francisco
Status:
Offline
|
|
still doesnt work 
|
|
we don't have time to stop for gas
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
do something like this: [php]$blogPath = "/full/path/to/blog/dir";
$blogPage = "index.php";
$blog = "$blogPath/$blogPage";
include $blog; [/php] this way, it's easier to change the paths if you test on a different server than the working script ends up on, or if you rename the script.
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2002
Location: England | San Francisco
Status:
Offline
|
|
okay, I am using an iframe until i get around to changing that bit, but... the alignment of the iframe text seems to stick it to one side, I dont see an option to change where the text wraps to the next line in the css :/
|
|
we don't have time to stop for gas
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Not too sure what you mean, but text-align: right; will put the text to the right. Althoguh, be careful (i.e. read the w3c specs as to what elements this will work on - there's some discrepencies, but, generally, text within a div is fine for aligning).
Or, just chuck it all in a <center> tag if you want it to go in the middle...
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2002
Location: England | San Francisco
Status:
Offline
|
|
I am not sure whats causing the text of the 'blog' to stick to the left hand side of the website.
|
|
we don't have time to stop for gas
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
stone the flamin' crows, ya flamin' galah. provide us with a working URL to check out, Peter, before Mundy turns into Alf Stewart again!
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
Use PHP to calculate the Path for you:
[php]
$link_url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . "page2.php";
[/php]
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2000
Location: Burlington, VT, USA
Status:
Offline
|
|
Originally posted by Diggory Laycock:
Use PHP to calculate the Path for you:
[php]
$link_url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . "page2.php";
[/php]
that will execute any php code before including it, I believe. Useuld use include( $_SERVER['DOCUMENT_ROOT'] . "/blog/page2.php" )
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2002
Location: England | San Francisco
Status:
Offline
|
|
Originally posted by philzilla:
stone the flamin' crows, ya flamin' galah. provide us with a working URL to check out, Peter, before Mundy turns into Alf Stewart again!
O_O
hejog.net
|
|
we don't have time to stop for gas
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
Originally posted by leperkuhn:
that will execute any php code before including it, I believe. Useuld use include( $_SERVER['DOCUMENT_ROOT'] . "/blog/page2.php" )
Yes - sorry, that was copy / pasted directly out of some code - I assumed that people would pick out the relevant bit 
|
|
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by Diggory Laycock:
Yes - sorry, that was copy / pasted directly out of some code - I assumed that people would pick out the relevant bit
never assume, Diggers. this is MacNN. 
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Are you sure php can't use relative paths for includes?
Using php5RC3 on a slackware linux box I have lying around at work allows reuired('something.whatever'); to work. I assumed required and include would use the same method of getting the file... or is it because I haven't included a path, just the name of a file in a directory?
I dunno - this euro2004 business is meaning I get drunk far too often (like I am now, and it's only 20 to 8... my body thinks it's still time to do things like posting here, but my brain just won't work. ah well).
Anyhoo - ignore me if I'm being a bit on the idiotic side (or even a lot).
|
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2000
Location: Burlington, VT, USA
Status:
Offline
|
|
Originally posted by Black Book:
Are you sure php can't use relative paths for includes?
Using php5RC3 on a slackware linux box I have lying around at work allows reuired('something.whatever'); to work. I assumed required and include would use the same method of getting the file... or is it because I haven't included a path, just the name of a file in a directory?
I dunno - this euro2004 business is meaning I get drunk far too often (like I am now, and it's only 20 to 8... my body thinks it's still time to do things like posting here, but my brain just won't work. ah well).
Anyhoo - ignore me if I'm being a bit on the idiotic side (or even a lot).
PHP can include relative paths, that's not a problem. The original problem had to do with using a absolute path relative to the root of the web site, which you can't do unless you use $_SERVER['DOCUMENT_ROOT'].
Of course, if you drop in an .htaccess file with a line that has
php_value include_path .:/path/that/you/want/to/use
then you can put your libraries in there, and not bother with relative and absolute paths at all.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|