Apache unable to run php script.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache unable to run php script.

Postby Aeon369 » 13. December 2015 01:52

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.



:-)
Aeon369
 
Posts: 3
Joined: 13. December 2015 01:26
Operating System: Win 7

Re: Apache unable to run php script.

Postby Nobbie » 13. December 2015 11:38

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.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Apache unable to run php script.

Postby Aeon369 » 13. December 2015 14:06

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?


:-)
Aeon369
 
Posts: 3
Joined: 13. December 2015 01:26
Operating System: Win 7

Re: Apache unable to run php script.

Postby Nobbie » 13. December 2015 17:11

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.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: Apache unable to run php script.

Postby Aeon369 » 13. December 2015 17:20

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..



:-)
Aeon369
 
Posts: 3
Joined: 13. December 2015 01:26
Operating System: Win 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 73 guests