PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 21st, 2012, 05:06 AM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
PHP5 - Error messages: PHP

Recently I got back to designing a website but now encountering a problem that didn't exist when I had given up for the time being

The error message I get is
Quote:
Undefined index: submit in F:\xampp\htdocs\Course1\index.php


The code that it points to is
Code:
if( "Login" == $_POST['submit'] )


I kept updating xampp and Netbeans continually between the time I gave up in which I had to delete htdocs and the mysql folders in the xampp folder in order for the application to un/install properly (of course I did back them up, but wouldn't recognise either if I had simply copied and pasted it back it)

I use mainly mysqli because that is what I was taught to use on my php course

Is this a xampp or localhost bug?

Reply With Quote
  #2  
Old November 21st, 2012, 05:17 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,882 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 9 h 58 m 26 sec
Reputation Power: 813
Hi,

well, I find the error message pretty straightforward. It says that there is no POST parameter named "submit". So you probably viewed the page for the first time when there has not been a previous form submission.

If you hadn't gotten this message previously it's because your PHP configuration supressed error message. So the problem always existed, but you just didn't see it before.

You can fix the problem with
PHP Code:
if( isset( $_POST['submit'] ) && "Login" == $_POST['submit'] ) 

But you might as well ignore the warning. Many developers tend to do that so that they can keep their code simple and don't have to add isset() everywhere.
Comments on this post
cssbonding agrees: wow, diddly wow, thank you

Reply With Quote
  #3  
Old November 21st, 2012, 05:34 AM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
wow, thank you that worked, forgot to say that I am receiving

Quote:
Undefined variable: message in F:\xampp\htdocs\index.php on line 52


PHP Code:
<?php if($message){echo("<p class='error_msg'>{$message}</p>");}?>


I hazard to guess that this is another suppressed error message that I am getting?

The variable $message has been defined earlier on

Reply With Quote
  #4  
Old November 21st, 2012, 05:38 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,882 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 9 h 58 m 26 sec
Reputation Power: 813
Quote:
Originally Posted by cssbonding
I hazard to guess that this is another suppressed error message that I am getting?


That's true. It's basically the same "error" as above: Instead of specifically checking for isset(), you just test if the variable is truthy. This isn't necessarily wrong, but it will trigger those warnings.



Quote:
Originally Posted by cssbonding
The variable $message has been defined earlier on


Maybe in another context (e. g. an "if" statement that isn't executed), but it's not defined at this point of time.

Last edited by Jacques1 : November 21st, 2012 at 05:40 AM.

Reply With Quote
  #5  
Old November 21st, 2012, 07:07 AM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
You mean it will work without the correction live? (my site isn't currently live in the internet)

Reply With Quote
  #6  
Old November 21st, 2012, 07:21 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,882 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 9 h 58 m 26 sec
Reputation Power: 813
This is a configuration issue, so it depends on the PHP configuration on your webserver. If the server is configured to not display any error message (like it should be), yes, your script will "work" in the sense that you won't see the warnings. If the configuration does display error messages, you'll either have to change it or overwrite it at runtime with error_reporting(0).

Last edited by Jacques1 : November 21st, 2012 at 07:24 AM.

Reply With Quote
  #7  
Old November 21st, 2012, 08:48 AM
Triple_Nothing Triple_Nothing is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 297 Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 8 h 45 m 39 sec
Reputation Power: 5
N just to toss my opinion in, if you feel Jacques1 is telling you to adjust your server's error reporting, I hope this is not true. Only production servers should have errors suppressed. Development servers, as it sounds you are currently on with the files, should be pumping out all tons of errors. This way the writer knows there's an issue and can correct the code, and not be mislead that everything is okay.

EDIT: And ya, if you changed if($message) into if(isset($message)), you shouldn't get that error.


EDIT2: Sorry. I overlooked the 'live' detail in your question. All should look good live as Jacques1 states.
Comments on this post
cssbonding agrees: thanks
Jacques1 disagrees: He specifically asked if the errors will show up on his *live* system. If the live system displays
any error messages, the configuration is wrong and must be changed or overwritten.

Reply With Quote
  #8  
Old November 21st, 2012, 09:03 AM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
Quote:
Originally Posted by Triple_Nothing
N just to toss my opinion in, if you feel Jacques1 is telling you to adjust your server's error reporting, I hope this is not true. Only production servers should have errors suppressed. Development servers, as it sounds you are currently on with the files, should be pumping out all tons of errors. This way the writer knows there's an issue and can correct the code, and not be mislead that everything is okay.

EDIT: And ya, if you changed if($message) into if(isset($message)), you shouldn't get that error.


I am currently on localhost because I don't want to put my files on the web unless there is a hoster where I can put up test files for at least six months where I can at least get back in the frame of mind of web development

Reply With Quote
  #9  
Old November 21st, 2012, 09:10 AM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
So I guess if there are any "if" statement, I have to insert "isset(variable or state)"?

Reply With Quote
  #10  
Old November 21st, 2012, 09:13 AM
Triple_Nothing Triple_Nothing is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 297 Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 8 h 45 m 39 sec
Reputation Power: 5
Well, only if it's written in the if($var) manner. Between the ()'s you are supposed to be pretty much writtin something that can be true/false. Your intent is to check if variable isset(). The reason for the error is because if the error is not set, it doesn't exist, so the if() cannot check if the statement is true or false.

Reply With Quote
  #11  
Old November 21st, 2012, 09:18 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,882 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 9 h 58 m 26 sec
Reputation Power: 813
Quote:
Originally Posted by cssbonding
So I guess if there are any "if" statement, I have to insert "isset(variable or state)"?


No.

As I already said, it's common practice to leave out the isset(). This is a valid way of coding. However, it will display those warnings while you work on your local test server (which is supposed to display all errors). You simply have to ignore them. When you put your scripts online, the warnings will not appear (if your live server is configured correctly and doesn't display any error messages).

If you cannot possibly live with warnings during development, yes, then you have to use isset().

Reply With Quote
  #12  
Old November 21st, 2012, 09:25 AM
Triple_Nothing Triple_Nothing is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 297 Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 8 h 45 m 39 sec
Reputation Power: 5
As Jacques1 states, the isset() is not truely required. I'm not really sure on over-all if peeps prefer it or not. I, tho, am one to try n write my scripts error-free to avoid poor possibilities down the road. If you are looking for a temp host or such, I can offer you space. As long as it's nothing huge and all, like forums with thousands of visitors, it will be all good.

Reply With Quote
  #13  
Old November 21st, 2012, 11:40 AM
msteudel's Avatar
msteudel msteudel is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712 msteudel User rank is Lance Corporal (50 - 100 Reputation Level)msteudel User rank is Lance Corporal (50 - 100 Reputation Level)msteudel User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
Quote:
As I already said, it's common practice to leave out the isset().


I would propose that if the PHP gods deems this a warning, that you should consider not testing to see if the variable exists as bad coding practice. IMO I think that you should strive to have zero warnings in your site. Just my 2 cents.

Reply With Quote
  #14  
Old November 21st, 2012, 12:22 PM
cssbonding's Avatar
cssbonding cssbonding is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 54 cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level)cssbonding User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 47 m 10 sec
Reputation Power: 9
Quote:
Originally Posted by msteudel
I would propose that if the PHP gods deems this a warning, that you should consider not testing to see if the variable exists as bad coding practice. IMO I think that you should strive to have zero warnings in your site. Just my 2 cents.


I know that because somehow something isn't quite working on my localhost like it used too, search functions are not working, plus plenty of other new error messages are appearing, I don't think that isset() is a good "fix"

Reply With Quote
  #15  
Old November 21st, 2012, 12:33 PM
msteudel's Avatar
msteudel msteudel is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2002
Location: Seattle, U.S.A.
Posts: 712 msteudel User rank is Lance Corporal (50 - 100 Reputation Level)msteudel User rank is Lance Corporal (50 - 100 Reputation Level)msteudel User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 4 Days 11 h 4 m 59 sec
Reputation Power: 11
Quote:
Originally Posted by cssbonding
I know that because somehow something isn't quite working on my localhost like it used too, search functions are not working, plus plenty of other new error messages are appearing, I don't think that isset() is a good "fix"


Actually adding isset or !empty IS the right fix. I bet that your application always had these warnings and I bet if you fixed them it would start working. If you don't want to fix the warnings then you can either add in

PHP Code:
 error_reporting(0); 


See this page for help on this:
http://php.net/manual/en/function.error-reporting.php

To the top of your pages or you can do it globally by editing your php.ini file:

Code:
display_errors = Off

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Error messages: PHP

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap