1
I am trying to include the config.php file that is in the site root folder. However, I also have the header.php file at the root of the site and all the pages are in a folder with this name, so the file is as follows.
<?php
include('../config.php');
include('../header.php'); ?>
conteudo...
</?php include('../footer.php);
For absolute link already tried:
include("http://".$_SERVER['SERVER_NAME']."/config.php");
Error displayed on the online server:
I didn’t succeed either. Warning : include(../config.php): failed to open stream: No such file or directory in /home/u655246247/public_html/pages/articles.php online 2
Line 2: that’s exactly where I’m going with this -> include('.. /config.php');.
On the localhost it still works perfectly. However, errors persist online, exactly the same. I echo the config.php file to test, and echo was included, but the connection variable is not found. Error: Warning : include(/home/u655246247/public_html/config.php): failed to open stream: No such file or directory in /home/u655246247/public_html/pages/texts.php on line 2
– Cobra
I will add the config.php file to the question for notes..
– Cobra
@Thiagobarros no use adding, it is not being read. Better include a directory listing
public_html
, to see permissions and names.– Bacco
Yes, but when I give an echo, the text is displayed on the page... why?
– Cobra
When do you give an echo where? Include a list of the public_html directory to see the permissions.
– Bacco
You don’t want to kill me, but the file was under another name on the online server.. rsrs After fixing, the online server showed me another error: Warning: include(): http://wrapper is disabled in the server Configuration by allow_url_include=0 in /home/u655246247/public_html/pages/texts.php on line 54
– Cobra
@Thiagobarros is because you are using http:// instead of the absolute path. And no, I don’t want to kill anyone, see item 3 that I had already added in the answer :) Remember that when you give include, the absolute path is the HD, not the web. The
$_SERVER['DOCUMENT_ROOT'];
gives you the root of your site, but in the way of HD.– Bacco
Let’s go continue this discussion in chat.
– Cobra