[SOLVED] PHP Include help

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
strangenetworks
New Member
New Member
Posts: 3
Joined: Sat Apr 18, 2009 3:56 am

[SOLVED] PHP Include help

Post 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?
Last edited by strangenetworks on Sat Apr 18, 2009 4:20 pm, edited 1 time in total.
uniqu3

Re: PHP Include help

Post 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');
strangenetworks
New Member
New Member
Posts: 3
Joined: Sat Apr 18, 2009 3:56 am

Re: PHP Include help

Post 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
pomfret
Forum Members
Forum Members
Posts: 14
Joined: Wed Dec 31, 2008 7:19 pm
Location: Connecticut, USA

Re: PHP Include help

Post 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
strangenetworks
New Member
New Member
Posts: 3
Joined: Sat Apr 18, 2009 3:56 am

Re: PHP Include help

Post 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
Post Reply

Return to “CMSMS Core”