php not executed

Alles, was PHP betrifft, kann hier besprochen werden.

php not executed

Postby croeltgen » 16. October 2010 17:14

Hello,
I have a problem with getting php to be executed on my localhost.
I have placed all html and php files in the same folder under C:\xampp\htdocs\projectname\
but php is ignored and theres no crash either. The same thing on a "real" server on the Internet works fine, so I guess I need to setup something somewhere to tell xampp to execute my php.
xampp runs fine, I can use phpmyadmin on localhost without problem.
Help is very much appreciated,
croeltgen
 
Posts: 15
Joined: 18. December 2008 12:22

Re: php not executed

Postby Knight1 » 16. October 2010 19:05

Hi
How do you call the PHP-File(s)?
Via http://localhost/ or C:\xampp\htdocs\projectname\?

To have PHP-Code executed, you must call the PHP-File(s) via http://localhost/ extendend by the Filename of your PHP-File.

Kai aka Knight1
Image
User avatar
Knight1
 
Posts: 310
Joined: 18. October 2003 10:03
Location: Trier
Operating System: Windows 7 Ultimate x64

Re: php not executed

Postby croeltgen » 16. October 2010 23:46

here's the code I have in my javascript in html file:

function getareas()
{
var resp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
resp=xmlhttp.responseText;
}
}
xmlhttp.open("GET","taxiareas.php",true);
xmlhttp.send();alert (resp);
return (resp);
}
the alert answers undefined.
My php starts with:
<?php
echo "test";return ;
...

As I said, on a real Internet server this executes just fine.
croeltgen
 
Posts: 15
Joined: 18. December 2008 12:22

Re: php not executed

Postby Altrea » 16. October 2010 23:55

How do you request your html/javascript file?
See Knight1s post.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: php not executed

Postby croeltgen » 17. October 2010 07:52

croeltgen
 
Posts: 15
Joined: 18. December 2008 12:22

Re: php not executed

Postby Altrea » 17. October 2010 08:56

Your Problem is not your PHP, your problem is your Javascript.
I don't know enough about Javascript to help you.

But my Firebug tells me, that your Script and your AJAX Request works quite fine.
You can test this with Firebug too, or just alert your resp variable after your line resp=xmlhttp.responseText;
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: php not executed

Postby croeltgen » 17. October 2010 09:35

when I execute the php file directly in the browser, it works fine. But when called within javascript it isnt invoked and "undefined" is returned in the alert.
This problem only happens locally and not on a server on the Internet...
my html and php are in the same directory. Could it be that this is the problem?
croeltgen
 
Posts: 15
Joined: 18. December 2008 12:22

Re: php not executed

Postby Knight1 » 17. October 2010 09:57

I'm not able to help on JS-Problems too.

wole wrote:... Das File (b2.html) muß die Extension php haben damit es durch den Server verarbeitet wird und an den Browser ausgegeben werden kann.


Die Datei b2.html wird wohl nur HTML und Javscript enthalten.
Der AJAX-Teil des Javascripts ruft die PHP-Datei taxiareas.php per GET auf.

The File b2.html will contain only HTML and Javascript.
The AJAX-Part calls the PHP-File taxiareas.php via GET.

@wole: Antworte bitte auf Englisch gestellte Fragen auch auf Englisch.


Kai aka Knight1
Image
User avatar
Knight1
 
Posts: 310
Joined: 18. October 2003 10:03
Location: Trier
Operating System: Windows 7 Ultimate x64

Re: php not executed

Postby croeltgen » 17. October 2010 10:28

I found the explanation of what goes wrong!
the xmlhttp.open request must be set to synchronous (3rd parm must be false instead of true), otherwise processing in javascript continues before server eventually answers.
there's no need to make the html file a php.

Thanks for having looked into this matter.
croeltgen
 
Posts: 15
Joined: 18. December 2008 12:22


Return to PHP

Who is online

Users browsing this forum: No registered users and 8 guests