Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 11-14-2006, 07:06 AM   #1 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Unhappy [PHP] Undefined Index??

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.

Server info: http://onwravens.net/phpinfo.php
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!

Last edited by Izzmo; 11-14-2006 at 07:18 AM.. Reason: Change Title
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 11:15 AM   #2 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
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.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 11:19 AM   #3 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
It's weird, because I've never had this problem before, so I'm trying to see why.

I just gave the isset() function as an example that will not work, so.

The original function I had was
Code:
if($i == "logout") { ... }
This did not work... so I'm trying to figure out why?

Doesn't that seem perfectly logical, it should work?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 11:49 AM   #4 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
It does seem logical. What's the code that's initializing $i?
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 11:54 AM   #5 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Well, it's not necessarily being initialized.

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.

Here are the two sites: exact same code.

http://www.onwswimming.net/index2.php
http://www.izzmo.com/swim/index2.php
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 12:04 PM   #6 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
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 ...
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 12:07 PM   #7 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Wow, I didn't even notice my server still had 4.4.3 on it...

They must of reinstalled it lol, cause it was version 5 a couple weeks ago.. hmmmmmm. This is the time I wish I had my dedicated server back

I'll try that StupidScript, thanks.

I'll inform you if it works or not.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 12:18 PM   #8 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Quote:
They must of reinstalled it lol
I wonder if they rolled back because of broken scripts?
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 12:21 PM   #9 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Lol, not sure exactly. I know they are bent on only installing stable versions, so maybe it wasn't stable enough? Not sure.

It's amazing how many changes the PHP Team does. I just looked at their ChangeLog, and they have to be doing at least 500 changes/fixes each version.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-14-2006, 12:36 PM   #10 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Ahhhh ... I love the smell of progress in the morning ...
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-17-2006, 12:20 AM   #11 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
Code:
if(isset($i == "logout")) { }
By order of evaluation this code is asking:

Is the equivalence of $i to "logout" a "set" variable?

The question (immediately above) doesn't make sense. We cannot ask if equivalences are set, we can also ask if they are true or false.

($i=="logout") returns a boolean. That boolean is passed to isset, which expects a variable.

First Evaluation: $i has the same contents as anonymous string "logout"
Possible Returns:
- true
- false
- I don't know, $i is not set <<< crash

Second Evaluation: has the variable in the isset argument been initialized?
Evaluation:

if $i=="logout" then this evaluates to:
if (isset(true)) {

if $i != "logout" then this evaluates to:
if (isset(false)) {

if $i is not set then this evaluates to:
if (isset(error thrown when comparing empty var to string))

In all three cases we haven't passed isset what it wants, which is an address in memory that either is or is not initialized.

You could replace that with this:

Code:
if (isset($i)) { if ($i=="logout") { logout(); } }
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-17-2006, 08:14 AM   #12 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo


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!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-17-2006, 10:54 PM   #13 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
I don't follow you Izzmo. If the code I suggest is the code that's on your site then what is the problem? Are you saying you can no longer say:
Code:
if (isset($varname)) {
The whole point of that function is so that you don't have to be explicit.
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-17-2006, 11:30 PM   #14 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
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!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-19-2006, 01:51 AM   #15 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
oh like

Code:
var $login; if (isset($login))
instead of

Code:
if (isset($login)) var $login;
?
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Old 11-19-2006, 06:23 AM   #16 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Well, something along those lines, yes.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 5 (0 members and 5 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript - Function is undefined (But I defined it, I swear!) pipelineae Coding Forum 1 03-09-2008 08:16 AM
How to redirect index.html to index.php and keep the same positions? sniperhiga SEO Forum 7 04-23-2007 07:51 AM
google index times and inital index? jasonstrempke Google Forum 10 04-24-2006 11:19 AM
help with css / z index I like pie Coding Forum 2 04-24-2006 06:08 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:52 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.