Page 2 of 2

Re: Big bug with $_GET

PostPosted: 09. February 2011 01:33
by jeggy
i got the same error, i have tried re install xampp and i have tried reinstall ubuntu many times.... please anyone who got it to work tell me how?
this is the only reason im not sure i want linux

Re: Big bug with $_GET

PostPosted: 09. February 2011 15:13
by Altrea
jeggy wrote:i got the same error

Which error?
There are several different error messages in this post.

Try again and give us as much information as possible you have about your error.
Post the full error message here, too.
And Post where you have the XAMPP install from and how you have installed it.

Re: Big bug with $_GET

PostPosted: 09. February 2011 16:01
by jeggy
code:
Code: Select all
<?php
$a = $_GET['u'];
echo $a;
?>

Notice: Undefined index: u in /opt/lampp/htdocs/index.php on line 2

on http://localhost/index.php , but when it is http://localhost/index.php?u=abc it works and print out "abc"

i downloaded it from http://www.apachefriends.org/en/xampp-linux.html#374
and followed the steps there..

Re: Big bug with $_GET

PostPosted: 09. February 2011 16:42
by Altrea
jeggy wrote:on http://localhost/index.php , but when it is http://localhost/index.php?u=abc it works and print out "abc"

Thats the correct behavior of php. What do you think is wrong with that?

If you want to use a variable or index and you don't know, if it is setted or not at this point, use the php functions isset() or empty() with it

Code: Select all
<?php
if(isset($_GET['u'])) {
    $a = $_GET['u'];
} else {
    $a = 'foo';
}
echo $a;
?>

Re: Big bug with $_GET

PostPosted: 10. February 2011 15:23
by jeggy
i didn't get that error on xampp in windows or on my site.
is there any way that i can install something to get it to work?

Re: Big bug with $_GET

PostPosted: 10. February 2011 16:21
by Altrea
"but my script is working fine on my online host" is a bad answer.
It just works there without this Notice because the Error Reporting Level of your Host is setted to a less strict setting.

Set your error_reporting online to E_ALL and you will get the same notices as ob your development environment.