Page 1 of 1

[SOLVED] PHP Include help

Posted: Sat Apr 18, 2009 4:06 am
by strangenetworks
I am trying to include a simple PHP script that will pull data from an HTML file located in another directory on my server.

If I could pull the data from the HTML file directly, that would work also.

I am trying to get this code to work in the CMSMS dir (public_html)

Code: Select all

 <?php $page_id="feedback"; include('view.php'); ?>
view.php is located at  public_html/feedback/view.php  so I changed it to

Code: Select all

<?php $page_id="feedback"; include('/feedback/view.php'); ?>
Which I thought would work.

I don't know how to get how to do the PHP Includes to work. I tried doing the UDT as followed:

Code: Select all

$page_id	="feedback";
include('view.php');
but I get this error on my page:

Code: Select all

Warning: include(view.php) [function.include]: failed to open stream: No such file or directory in /home/stranget/public_html/lib/content.functions.php(857) : eval()'d code on line 2

Warning: include(view.php) [function.include]: failed to open stream: No such file or directory in /home/stranget/public_html/lib/content.functions.php(857) : eval()'d code on line 2

Warning: include() [function.include]: Failed opening 'view.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/var/cpanel/3rdparty/lib/php') in /home/stranget/public_html/lib/content.functions.php(857) : eval()'d code on line 2
What am I doing wrong?

Re: PHP Include help

Posted: Sat Apr 18, 2009 9:26 am
by uniqu3
looks like your path to the file isnt correct.
you said the file is in /feedback folder then the udt call should be:

Code: Select all

include('/feedback/view.php');

Re: PHP Include help

Posted: Sat Apr 18, 2009 2:08 pm
by strangenetworks
I tried that and I get this error.

Code: Select all

Warning: include(/feedback/view.php) [function.include]: failed to open stream: No such file or directory in /home/stranget/public_html/lib/content.functions.php(857) : eval()'d code on line 1

Warning: include() [function.include]: Failed opening '/feedback/view.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/var/cpanel/3rdparty/lib/php') in /home/stranget/public_html/lib/content.functions.php(857) : eval()'d code on line 1

Re: PHP Include help

Posted: Sat Apr 18, 2009 2:41 pm
by pomfret
Try:

Code: Select all

include('/home/stranget/public_html/feedback/view.php');
If that works, you should be able to change it to:

Code: Select all

include($_SERVER['DOCUMENT_ROOT'].'/feedback/view.php');
Which will help if your home public_html directory ever changes.

Brian

Re: PHP Include help

Posted: Sat Apr 18, 2009 4:15 pm
by strangenetworks
Thanks alot, it worked. I don't know what I was thinking, I forgot about using the server dir info  ???

Lol, it's been while since I have worked with PHP