Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-28-2006, 08:00 PM   #1
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
PHP Include - Host has uneditable php.ini file

I'd like to use the PHP include(), but I am afraid that my hosts php.ini file does not contain the include_path option and I don't want to go editing the php.ini file as I am still learning my way through it and I don't want to mess it up too much.

I've read about using the
PHP Code:
ini_set('include_path''.'); 
method as well, but this doesn't seem to work the way I have it set up. Is there something else I need to have as well?

I've got one more question. When including a file with include()... do I have to specify the server, or will it take the file straight from the directory of the current html document?

thanks,
Ryan
__________________
RiotCats.com, an internet domain specifically fabricated and visually erected for the appreciation of the feline kingdom!
rspassey is offline   Reply With Quote
Old 09-28-2006, 08:14 PM   #2
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Using

include("somefile.php");

doesn't work? I'm not sure about the ini file, but it'll take the file relative to the current file (no need to specify server).

Also you mention "html document". You're not trying to run php from a .html file are you?
__________________
"It is the way of man to make monsters and it is the nature of monsters to destroy their makers."
blue60007 is offline   Reply With Quote
Old 09-28-2006, 08:29 PM   #3
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
It's a .php file... which is what I think I'm supposed to use... but it still doesn't work like this:

PHP Code:
<? php
include('header.php');
?>
Bear with me here, I've barely started studying php .


EDIT: Now I'm getting this error : Parse error: parse error, unexpected T_INCLUDE in /home/content/r/p/a/rpassey/html/index4.php on line 2

Last edited by rspassey; 09-28-2006 at 09:30 PM.
rspassey is offline   Reply With Quote
Old 09-28-2006, 09:41 PM   #4
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
You don't need to edit the php.ini file even if you could. All the include file directive tells php is the default location to look for your included file. As long as you tell it where the include file is it is not necessary to change the php.ini file.

You are getting the parse error because you have a space between the ? and php.
It should be <?php not <? php.
__________________

Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row
mairving is offline   Reply With Quote
Old 09-28-2006, 10:12 PM   #5
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
Quote:
Originally Posted by mairving
You don't need to edit the php.ini file even if you could. All the include file directive tells php is the default location to look for your included file. As long as you tell it where the include file is it is not necessary to change the php.ini file.

You are getting the parse error because you have a space between the ? and php.
It should be <?php not <? php.
Thanks for the info!. It worked like a charm.

PHP seems to be a pretty picky language... I think I really should take a "class" on it.

Thanks again,
Ryan

Edit.. one last question: is there a prefered file type for included headers and footers and what not? I'm using .inc right now, because that's what my php book shows me, but I've seen a few online tutorials using .php for their header.

Last edited by rspassey; 09-28-2006 at 10:16 PM.
rspassey is offline   Reply With Quote
Old 09-28-2006, 10:18 PM   #6
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally Posted by rspassey
Thanks for the info!. It worked like a charm.

PHP seems to be a pretty picky language... I think I really should take a "class" on it.

Thanks again,
Ryan
No, it's not really picky. You can open a php command by <? or <?php . When you put the space between the php, it tried to parse your code and opening with the short version <? then it hit php. Well that wasn't a string and it wasn't a function so it spit out your parse error. FYI, it is a good idea to use <php .
mairving is offline   Reply With Quote
Old 09-29-2006, 03:03 PM   #7
Wx geek
 
blue60007's Avatar
 
Join Date: Aug 2005
Location: Indiana
Posts: 6,638
Quote:
Originally Posted by rspassey
PHP seems to be a pretty picky language... I think I really should take a "class" on it.
One thing I found handy while working with PHP (I'm still learning all there is to it still) is to test it on a local webserver (ie, use AppServ to set one up). Sure beats uploading the php file to your server to find you forgot a ; or something silly like that, and re-uploading again.
blue60007 is offline   Reply With Quote
Old 09-29-2006, 03:12 PM   #8
~ Ryan ~
 
Join Date: Jun 2005
Location: Jackson TN
Posts: 3,516
Send a message via AIM to rspassey Send a message via MSN to rspassey
Quote:
Originally Posted by blue60007
One thing I found handy while working with PHP (I'm still learning all there is to it still) is to test it on a local webserver (ie, use AppServ to set one up). Sure beats uploading the php file to your server to find you forgot a ; or something silly like that, and re-uploading again.

Sound advice... thanks.

I've got another PC coming in my sea shipment, so when it gets here, I can set one of my linux boxes up as a test server.
rspassey is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External Dvd Burner Not Working PreDeadMan Computer Hardware 1 09-17-2005 03:48 PM
Antivirus broken, HJT logfile EDB Networking & Online Security 6 09-12-2005 12:21 PM
Centering include file asp racerxfactor Web Design / Development 2 08-22-2005 10:12 PM
Backing up Outlook Express keifir Windows Legacy Support (XP and earlier) 9 08-17-2001 05:06 PM
Dos in Win98SE Charles Windows Legacy Support (XP and earlier) 36 07-30-2001 11:59 PM


All times are GMT -5. The time now is 05:13 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2