Php include not working on Wordpress/ subdomain?

We have this functioning php-snippet:

<?php include($_SERVER['DOCUMENT_ROOT'].'/iapath/iapathlist.php');?>

It works fine,

however, when it is put into a Wordpress page on a subdomain wp3 = wp3.mywebpage.org, which is hosting the Wordpress part of the site, then it doesn’t work.

Of course we use the absolute path in this case.

<?php include($_SERVER['DOCUMENT_ROOT'].'https://www.mywebpage.org/iapath/iapathlist.php');?>

There is also a simple php date snippet running fine.

What can be the reason it, doesn’t compile?

/

with best regards, Omar KN, Stockholm, Sweden

“Absolute path” doesn’t mean “URL”. A URL is how a http client (such as a web browser) finds your file; an absolute path is the file system path from the root to your file. You can’t use them interchangeably.

Have you tried your original code on your subdomain? If it didn’t work, what was the error?

I put the file on the wp3 subdomain

https://www.livingislam.org/wp3.livingislam.org/nlinks.php

[php = no success]

<?php
include ($_SERVER['DOCUMENT_ROOT']. 'https://www.livingislam.org/wp3.livingislam.org/nlinks.php');

When I have it on my static page @ main domain, then this is the php:

<?php include($_SERVER['DOCUMENT_ROOT'].'/m/nlinks.php');?>
<br />	

My error-log is not updating right now (why?), the last entry was:

[09-Nov-2021 19:34:50 UTC] PHP Warning: include(): Failed opening ‘/home/livingis/wp3.livingislam.orgwp3.livingislam.org/nlinks.php’ for inclusion (include_path=’.:/opt/alt/php73/usr/share/pear’) in

/home/livingis/wp3.livingislam.org/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(97) : eval()'d code on line 2


older log entry

[24-Oct-2021 16:29:34 UTC] PHP Warning: include(/home/livingis/wp3.livingislam.org…/wp3.livingislam.org/nlinks.php): failed to open stream: No such file or directory in

/home/livingis/wp3.livingislam.org/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(97) : eval()'d code on line 2

.

It might be a path issue, -

/

with best regards, Omar KN, Stockholm, Sweden

Sponsor our Newsletter | Privacy Policy | Terms of Service