Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Undefined index error

  1. #11
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default

    When you take the time to write truly well-formed code that does not exploit (novice) shortcuts like global variables and etc, you will appreciate why this is set to report ALL errors.

    Advantages:

    1) Your code will be more portable and compatible.

    2) Your code will be more secure.

    3) You spend less time debugging your code.

    4) You gain valueable experience coding as a real developer (see #3)


    Now, if you are working on a project and are working under a rapid-development strategy, that is what shortcuts are for. You don't have to define all your variables before you use them, and you can expect your HTML form $_GET and $_POST vars to magically fall from the sky all nice and pre-defined for you.

    Since OR2 is a complete rewrite, and is aimed toward more professional (larger) deployments, it adheres to more stringent W3C and accepted coding standards. It definitely takes more time initially to write code that will pass an errorlevel of E_ALL, but after you do it for a few projects, you will begin to do it naturally, as you should..
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  2. #12
    Join Date
    Aug 2004
    Location
    United States of America
    Posts
    668

    Default

    I guess I can see that, My code is often ugly but functional.
    Do you know of other projects that model their code this way?

    One strange thing I just thought about. Is there such a thing as hadron remnant light, like bud light or something. I thought it had to do with number of posts.

    Jared
    Last edited by jared; 05-17-2005 at 09:05 PM.

  3. #13
    Join Date
    Jan 2005
    Posts
    349

    Default

    Right, so if I write if($_POST[action]) and there is no action this time since we have just come to the page you say I am wrong, substandard or shabby. I really think that is funny strange, not funny ha ha. What this does is makes fairly standard code useless, nothing more. Actually what this represents is the desire to control the code. That is fine since he owns it, but it does not make other code bad or insecure or shabby. What it does is makes people who could contribute things, both free and paid, just walk away.

    Just because some coding model is chic or in fashion at the moment does not make it per se better, just different. Adding more lines to code simply to avoid display of notices that the manual for the language states can be part of normal operation of a script is not efficient. Often times it makes for code that is quite difficult to modify should the need arise. It definitely takes more resources.

    Just how is the absence of a value for a particular $_POST variable that may in some operation be set insecure shabby or unprofessional?

  4. #14
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default

    If you mean coding to work with PHP error reporting set at E_ALL, I would have to say any professional-grade commercial project.. Rapid development methods are for showing the app to the client/investor/boss but it is usually expected that after the client/investor/boss has signed-off on the functionality of the app, that all the shortcuts be removed and the code "tightened-up", which isn't usually too hard or time consuming..

    When we're talking about 1-off projects for clients at < $500 I wouldn't expect anyone to bother with E_ALL, because chances are it won't have to move, scale, or earn a substantial living for the client. When your app is intended to find its way into the hands of many different users, good code is happy code.

    Good coding standards can also dramatically affect scalability, which was the Achilles heel of OR 1.x.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  5. #15
    Join Date
    Jun 2004
    Posts
    1,067

    Default

    With a project the size of OR, the largest reason for using EALL is that it make sure that we run on all servers, leaving code in that causes notice errors may have no working effect on code, but if even a few percent of the servers running OR use EALL it becomes a large issue quickly as most users just assume the software if broken when they see the error and move on. OR 1.x was full or coding issues like this, and the support forms reflected the problems with constant questions about issues that are no longer present in the 2.0 release.

  6. #16
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default

    Well, put most simply, but not entirely accurate:

    A "hadron remnant" is what remains (the leftover subatomic residue or radiation) once the hadrons (protons, neutrons & quarks) have been broken or smashed apart in an element.

    Hadron remnants are currently produced in supercolliders by smashing gold or copper ions together at near speed of light velocities.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  7. #17
    Join Date
    Jan 2005
    Posts
    349

    Default

    Quote Originally Posted by greengiant
    With a project the size of OR, the largest reason for using EALL is that it make sure that we run on all servers, leaving code in that causes notice errors may have no working effect on code, but if even a few percent of the servers running OR use EALL it becomes a large issue quickly as most users just assume the software if broken when they see the error and move on. OR 1.x was full or coding issues like this, and the support forms reflected the problems with constant questions about issues that are no longer present in the 2.0 release.

    Okay, I get that point then. It is unfortunate that it is necessary to work down to the most poorly configured server, but I suppose that is the nature of free scripts. It is interesting to note that the servers in question are also the least likely to benefit from the increased server load from the additional code.

    On the other hand there is no question that running a production server showing errors is not in the realm of best practices. In fact if we grant tsk his assertion of a professional grade commercial script then one is left wondering how securing its operation on poorly configured servers is going to help. I guess what I am saying is that just because code makes php notices does not mean that there is anything wrong with it at all.

    This line:

    if ($_POST['process']=="update")

    is not wrong or sloppy in the event that $_POST[process] is not set.

    It is also not efficient to test if (isset($_POST['process'])) to avoid the notice when this index is a component of a complex logic tree below that is not necessarily dependent on this value since it may not be a primary or even secondary switch in the logic. This is why the manual talks of such things happening in the normal operation of the script. I'll shut up after saying that I just cannot see bulking the code with isset switches to stop a few notices though I understand Ryan's logic doing it in this case.

  8. #18
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default

    Quote Originally Posted by tombones
    I guess what I am saying is that just because code makes php notices does not mean that there is anything wrong with it at all.
    When itls only notices that do not actually affect the operation of the app, I completely agree. I get more on a soapbox about people depending on global variables while running in a production enviornment. When you know where your script will be running, you have a lot of accomodation, but when you don't, eliminating anything that looks and smells to the end user like an "error" (even if non-fatal), is greatly appreciated by the support staff.. Whan the support dept is just yourself, it can open up windows of opportunity to have a life... maybe..


    Suppressing errors can be like taking morphine to cure a gunshot wound. E_NOTICE errors are more like a near miss in this analogy I suppose.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  9. #19
    Join Date
    Aug 2004
    Location
    United States of America
    Posts
    668

    Default

    sandking;

    I've learned that many of the notices that do pop up have little to do with actual errors. Case in point is a modification to the listings.inc.php where we wanted more than just a photo with the featured listings. The function was modified and worked flawlessly but the pesky errors needed to be surpressed by and .htaccess flie to have the page appear correctly. We later solved the notice issue and all is well.

    But as you stated customers who see the notice tend to freak out thinking their site has been hacked or something.

    My own rant;
    Jared

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •