Page 1 of 1

Apache unable to run php script.

PostPosted: 13. December 2015 01:52
by Aeon369
Hello everybody.

I'm new to xampp/apache, apologies if this is a stupid question.
I have xampp 3.2.1 installed on my PC.
I'm trying to implement a php contact form trough a "php include" function.

Stand alone the scipt itself is working fine,
it is when I try to cal the script trough a "php include" function that things get weird.

This is the code I'm using:

<?php include ($_SERVER["DOCUMENT_ROOT"] . "/nb/kontakt/contact.php"); ?>

Script is showing up but is not working?

This is the error log:

'C:/xampp/htdocs/nb/contact.php' not found or unable to stat, referer: http://localhost/nb/index.php

As one can see, the script is called from "/nb/kontakt/contact.php"
but apache is trying to find the script in "/nb/contact.php"

Can some plz advise me how to fix this, I would be very gratefull.



:-)

Re: Apache unable to run php script.

PostPosted: 13. December 2015 11:38
by Nobbie
First of all, create a variable for the filename and echo it (in order to check it):

Code: Select all
$contact = $_SERVER["DOCUMENT_ROOT"] . "/nb/kontakt/contact.php";
echo $contact;
<?php include ($contact.php); ?>
echo "After Include";


After then compare the output with your error message, i am pretty that you either execute the wrong file, or debug the wrong line. It is definately impossible for PHP to skip the "/kontakt" part of the string.

Re: Apache unable to run php script.

PostPosted: 13. December 2015 14:06
by Aeon369
Nobbie wrote:First of all, create a variable for the filename and echo it (in order to check it):

Code: Select all
$contact = $_SERVER["DOCUMENT_ROOT"] . "/nb/kontakt/contact.php";
echo $contact;
<?php include ($contact.php); ?>
echo "After Include";


After then compare the output with your error message, i am pretty that you either execute the wrong file, or debug the wrong line. It is definately impossible for PHP to skip the "/kontakt" part of the string.



To be honest, I'm a total nube.
I don't exactly know what to do with code snippet you provided?


:-)

Re: Apache unable to run php script.

PostPosted: 13. December 2015 17:11
by Nobbie
I cannot teach you PHP, if you do not understand this snippet and dont know what to do, it is too hard for me to help you out of there.

Re: Apache unable to run php script.

PostPosted: 13. December 2015 17:20
by Aeon369
Nobbie wrote:I cannot teach you PHP, if you do not understand this snippet and dont know what to do, it is too hard for me to help you out of there.



I understand.

Thank you very much for your answer..



:-)