Okay, out of all of my years in PHP, I've never came across this before.
Here is the error: Notice: Undefined variable: i in E:\wwwroot\onwswimming.net\index2.php on line 3
I'm not sure why it's coming up, it doesn't make sense.
Here is the background:
I developed this website originally on my webserver, which is a Red Hat Linux server with PHP & MySQL. Since they wanted to buy their own hosting, I had to move it over to their new web server for them. The server I moved the site + database to is a Windows IIS with MS SQL (PHP Installed). I don't know the error came up, the versions are the same, and it doesn't have anthing to do with the database extension for PHP I had to install for MS SQL.
So, has anyone came across this error and know how to fix it?
Also, I have done the isset() function on other occasions, but you can't do this for isset():
Code:
if(isset($i == "logout")) {
}
So, is there another variable in place to do this? I've never came across this error, EVER! So, it's a whole new thing to me unfortunately.
You are using two kinds of checks in your control structure: isset and ==. I believe in this case the isset is what's causing your error whenever variable $i has not been initialized.
Code:
if($i && $i=="logout") {
would be the extended illustration of (perhaps) what you are trying to do. In practice,
Code:
if($i=="logout") {
would have the desired result. Not only must $i have been initialized, but it also must have the value "logout". If $i is neither, it won't match.
Here is what is happening. I have it setup so if I user wants to logout, the Admin, the url will be index2.php?i=logout.
In the code, it check to see if i is set to the string: logout. If it is, it checks to see if the admin cookie is set, and if that is set, it will log them out and erase the cookie.
Hmmm. PHP 5.x ... well ... thinking aloud ... register_globals is being handled a little differently than with v.4.x, and it generally prefers a variable to have been initialized before use (general practice, but loosely enforced), so maybe try
Code:
$iA=0; //init temp var
$iA=$_GET["i"];
if($iA=="logout") {
?
I realize that $i _seems_ to have been initialized by its inclusion in the $_GET array, however maybe this is where the snafu lives ... in the translation between the two ...
I know this doesn't work. I said above, that it doesn't work and I was wondering why.
The actual code I had in my site was the second example you showed.
But with PHP 5.x, this is not possible, and since they made it more 'explicit', you have to set the variable i before you ask about it. Which makes sense.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Well, this functionality works in PHP 4.2.x, but in the new 5.x versions, they changed it so you have to state the variable before you use the isset() function now. Which is odd, but I'm still doing some checking around on this.
Once again, it works fine for me on my server, which is 4.2.3, but on my clients servers, it is 5.x.x, so I have to do some research on it.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!