Page 1 of 1

Strange URL Query String issue

PostPosted: 08. September 2010 00:02
by airchie
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 :)

Re: Strange URL Query String issue

PostPosted: 08. September 2010 00:15
by Altrea
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.

Re: Strange URL Query String issue

PostPosted: 08. September 2010 00:29
by JonB
$_GET['aPHPTutorial']; :shock:

:mrgreen:

Re: Strange URL Query String issue

PostPosted: 08. September 2010 00:32
by Altrea
even better:

$_GET['a_PHP_Tutorial_which_is_up_to_date_and_not_about_php3']

:mrgreen: :mrgreen:

Re: Strange URL Query String issue

PostPosted: 08. September 2010 16:23
by airchie
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

Re: Strange URL Query String issue

PostPosted: 08. September 2010 17:48
by WilliL
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

Re: Strange URL Query String issue

PostPosted: 09. September 2010 04:00
by Altrea
And another great tutorial:
http://tut.php-quake.net/en/