Problem with php

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

Problem with php

Postby php_user » 03. January 2009 21:34

Hello. I have some problem with php and xampp. So, I'll try to explain. Well, I create php file:
Code: Select all
<?php

echo "hello, $name";

?>


Everything is ok, when I put just a path to file. But when I put in browser:
Code: Select all
localhost/index.php?name=everyone
nothing happens. May you help me with this problem? Thank you and sorry for my English.
php_user
 
Posts: 4
Joined: 03. January 2009 21:20

Re: Problem with php

Postby dmphotography » 03. January 2009 21:51

Ok,
Your information is a bit vague, but if I understand what you're trying to do, perhaps this is your problem.

I don't know very much about PHP, but it looks like what you're doing should work.

The question I have is are you sure you put the php file in the root directory?

In order to access it, you should put it in your htdocs folder.

If this is correct and you know for sure it's going to the file, then perhaps there's a problem with your syntax.

I hope that helps.
For great video and written tutorials and guides on creating your own web server and installing things such as forums, blogs, etc., visit http://myownhomeserver.com
dmphotography
 
Posts: 191
Joined: 15. December 2008 14:25
Location: Columbus, MS
Operating System: Windows 7

Re: Problem with php

Postby php_user » 03. January 2009 22:00

Yes, I put this file in htdocs folder.

About wrong code: I put the file to hosting (server) and it works.

So, I mean when I write "localhost/index.php?name=everyone" browser must show "hello, everyone", but it doesn't when I use xampp. Sorry for my English one more time (:
php_user
 
Posts: 4
Joined: 03. January 2009 21:20

Re: Problem with php

Postby Wiedmann » 03. January 2009 22:48

But when I put in browser: localhost/index.php?name=everyone nothing happens.

That's wrong:
You have the output: "hello, ".


Code: Select all
<?php echo "hello, $name"; ?>

So, I mean when I write "localhost/index.php?name=everyone" browser must show "hello, everyone",

Not with your current code.

Put a "error_reporting(E_ALL);" as first statement in your script, and you can see the problem:
The variable "$name" does not exists.

Maybe you want use:
Code: Select all
<?php echo "hello, {$_GET['name']}"; ?>

(Please read the PHP manual about "external Variables".)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Problem with php

Postby php_user » 03. January 2009 23:08

Thank you very much! But when I upload file to the hosting (or server) it works and output is "hello, everyone".....
php_user
 
Posts: 4
Joined: 03. January 2009 21:20

Re: Problem with php

Postby Wiedmann » 03. January 2009 23:30

But when I upload file to the hosting (or server)

Maybe... This hosting provider have enabled a PHP option, which is default disabled in PHP since 7 years (because of security resons)... This option will be also completely removed in the next major PHP version.

(BTW: You can read this yourself in the PHP manual, chapter "external variables". You remember my last post?)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Problem with php

Postby php_user » 03. January 2009 23:37

Wiedmann wrote:
But when I upload file to the hosting (or server)

Maybe... This hosting provider have enabled a PHP option, which is default disabled in PHP since 7 years (because of security resons)... This option will be also completely removed in the next major PHP version.

(BTW: You can read this yourself in the PHP manual, chapter "external variables". You remember my last post?)

Ok, thank you! I'll read now, 'cause I'm beginner at php)))
php_user
 
Posts: 4
Joined: 03. January 2009 21:20


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 48 guests