A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearAbsolute paths for PHP include - page 1
User InfoPosts
Absolute paths for PHP include#1
Ok I'm at my work this friday setting up a table that will have data in it that will come from a separate file called values.php. When I write it like this, the divs turn up blank. I think I have the "include" written wrong, does an absolute path not work?

<?php include('http://www.nextadvisor.com/credit_report_services/values.php'); ?>

<div class="box_text">
<div class="box_image">
<a href="<?php echo $offer1link ?>" target="blank"><img src="<?php echo $offer1logo ?>" alt="<?php echo $offer1name ?>"></a></div>
<div class="box_rating">
Rating:<span class="star_rating"><img src="<?php echo $offer1star1 ?>" alt=""></span><br>
<div class="rating_review"><a href="<?php echo $offer1link ?>" target="blank">Go to Site</a> | <a href="<?php echo $offer1anchor ?>">Review</a></div> </div>

<br style="clear: both;">

Oh and thanks in advance for any help you can give. Anyone who has helps me is the greatest. I feel bad cause sometimes two people answer the question and I can't give the green check to both.

posted date: 2008-12-19 16:07:00

Re: Absolute paths for PHP include#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-19 16:07:01

Re: Absolute paths for PHP include#3
Provide the source of the other PHP file as well.. Also if the file reside on the same server, it's best to use a path, not a URL

posted date: 2008-12-19 16:10:00

Re: Absolute paths for PHP include#4
Absolute filename is something like /path/to/file.php as you would access the file from anywhere in the file system hierarchy.If its in the same dir, or relative to the same dir, you can use something likeinclude dirname(__FILE__) . '/file.php';include realpath(dirname(__FILE__) . '/../dir') . '/file.php';include realpath(dirname(__FILE__) . '/../dir/file.php');You should probably make some constants likedefine('BASEDIR', dirname(__FILE__));define('LIBDIR', BASEDIR . '/lib');

posted date: 2008-12-19 16:28:00

Re: Absolute paths for PHP include#5
According to the manual its enabled by default, but that might be wrong. In which case it should be reported. Quote: If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL

posted date: 2008-12-19 16:31:00

Re: Absolute paths for PHP include#6
Since you're using a URL, PHP will send a request to the server for the file, and the server will parse it just as it would if a browser requested it. What you probably want to do is use a path relative to the script for your include. If the file you want to include is in the same folder, just useinclude('values.php');

posted date: 2008-12-19 16:39:00

Re: Absolute paths for PHP include#7
thanks. thanks OIS and tenebrous also for their help!

posted date: 2008-12-19 16:41:00

Re: Absolute paths for PHP include#8
You have a fundamental misunderstanding how urls and php work, PHP is a script that runs on a server and outputs HTML. You can't run another site's PHP remotely, all you can do is receive the HTML it outputs.

posted date: 2008-12-19 19:41:00

Re: Absolute paths for PHP include#9
The allor_url_include directive is disable by default since PHP 5.2.0

posted date: 2008-12-21 10:20:00

Re: Absolute paths for PHP include#10

posted date: 2008-12-21 10:21:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.