Strange URL Query String issue

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

Strange URL Query String issue

Postby airchie » 08. September 2010 00:02

Hi All,

I've just decided to get back into web design after a long spell away from it so I'm quite rusty.
I am going through some tutorials and have a strange issue with URL query strings I'm hoping you can help me solve.

I have a simple PHP file called welcome.php containing the following:
Code: Select all
<?php
  echo( "Welcome to our Web site, $name!" );
?>


If I open the page with the following URL:
http://localhost/welcome.php?name=john

I get the page up but only showing the following:
Welcome to our Web site, !


I've tried a few other URL query string type pages and it seems that the PHP interpreter isn't picking up the variables from the URL.
I suspect I'm missing something obvious but will be glad of any assistance.

Thanks in advance
airchie :)
airchie
 
Posts: 2
Joined: 07. September 2010 23:52

Re: Strange URL Query String issue

Postby Altrea » 08. September 2010 00:15

Try this:

Code: Select all
<?php
  if (!empty($_GET['name'])) {
    $name = $_GET['name'];
  }
  echo( "Welcome to our Web site, $name!" );
?>


Since register_globals is set to off (and should leave deactivated because of security reasons) (Super-)global Array Keys no longer register local pendants automatically. You must take care on your variables by yourself.
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Strange URL Query String issue

Postby JonB » 08. September 2010 00:29

$_GET['aPHPTutorial']; :shock:

:mrgreen:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Strange URL Query String issue

Postby Altrea » 08. September 2010 00:32

even better:

$_GET['a_PHP_Tutorial_which_is_up_to_date_and_not_about_php3']

:mrgreen: :mrgreen:
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Strange URL Query String issue

Postby airchie » 08. September 2010 16:23

lol, thx guys. :D
I had a feeling it'd be something obvious. :oops:

Any suggestions on tutorials or good websites with guides etc?

Cheers,
airchie
airchie
 
Posts: 2
Joined: 07. September 2010 23:52

Re: Strange URL Query String issue

Postby WilliL » 08. September 2010 17:48

one of my prefered side, http://www.w3schools.com/PHP/php_intro.asp to have a quick look for a build in function and how to use
and of course http://www.php.net/manual/en/index.php
Willi
WilliL
 
Posts: 660
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: Strange URL Query String issue

Postby Altrea » 09. September 2010 04:00

And another great tutorial:
http://tut.php-quake.net/en/
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: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 176 guests