My website uses PHP include to bring-in all sorts of things as .html files and dumps them into my main page. It was working flawlessly - until my host, "upgraded" my package, and now it's stopped working completely. When they've tinkered about, they moved everything around and now the folder where everything was kept has been changed. It might be a path problem, but I've updated the .htaccess and it's still not working. I've tried a few tricks in my index file and that still doesn't work. Nightmare !
Can anyone help ?
Thanks !
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="_CustomCSS/CustomCSS.css" rel="stylesheet" type="text/css">
<?php include_path = ".:/home/MyUserName/public_html/" ?>
<?php define("HTTP_ROOT1", "http://www.tunedinevents.co.uk"); ?>
<link href="<?=HTTP_ROOT1?>/__Testing/Include_PHP/_CustomCSS/Include_Red_CSS.css" rel="stylesheet" type="text/css">
<link href="<?=HTTP_ROOT1?>/__Testing/Include_PHP/_CustomCSS/Include_Green_CSS.css" rel="stylesheet" type="text/css">
<link href="<?=HTTP_ROOT1?>/__Testing/Include_PHP/_CustomCSS/Include_Blue_CSS.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php include_path = ".:/home/MyUserName/public_html/" ?>
<div class="<?php include $_SERVER['DOCUMENT_ROOT'].'/__Testing/Include_PHP/_CustomCSS/Include_Red_CSS.html'; ?>"></div>
<div class="<?php include $_SERVER['DOCUMENT_ROOT'].'/__Testing/Include_PHP/_CustomCSS/Include_Green_CSS.html'; ?>"></div>
<div class="<?php include $_SERVER['DOCUMENT_ROOT'].'/__Testing/Include_PHP/_CustomCSS/Include_Blue_CSS.html'; ?>"></div>
<div class="Class_Box_1" id="ID_Text_Red">If PHP works properly, this text will be Red</div>
<div class="Class_Box_2" id="ID_Text_Green">If PHP works properly, this text will be Green</div>
<div class="Class_Box_3" id="ID_Text_Blue">If PHP works properly, this text will be Blue</div>
</body>
</html>
My Answer:
It looks like you are trying to set the include path using the wrong syntax. Instead of using `include_path = ".:/home/MyUserName/public_html/"`, you should use `set_include_path(".:/home/MyUserName/public_html/")`.
Try updating your code to the following:
php
And for including the HTML files, you should use `include` without `$_SERVER['DOCUMENT_ROOT']`:
php
Make sure that the paths to the HTML files are correct relative to the current file location. If they are not in the same directory, you may need to adjust the paths accordingly.
Hopefully, this helps resolve the issue with your PHP includes not working after the hosting upgrade. Let me know if you need further assistance.
Rate this post
3 of 5 based on 3730 votesComments