Page 1 of 1

Problem with php

PostPosted: 03. January 2009 21:34
by php_user
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.

Re: Problem with php

PostPosted: 03. January 2009 21:51
by dmphotography
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.

Re: Problem with php

PostPosted: 03. January 2009 22:00
by php_user
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 (:

Re: Problem with php

PostPosted: 03. January 2009 22:48
by Wiedmann
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".)

Re: Problem with php

PostPosted: 03. January 2009 23:08
by php_user
Thank you very much! But when I upload file to the hosting (or server) it works and output is "hello, everyone".....

Re: Problem with php

PostPosted: 03. January 2009 23:30
by Wiedmann
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?)

Re: Problem with php

PostPosted: 03. January 2009 23:37
by php_user
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)))