Background Image
Web
Development
Tools
Tool...
49 Projects
Web Development Project
Web
Development
Project
Programming Guide: Code debugging
Creator:Graphix
Last edit:2010-11-02 19:33:08

As described in the Code Guidelines you need to have a editor with syntax highlighter as this will help you debug code. See the Code Guidelines for links.

  • Basic principles for all programming languages:

    • You always need to echo/messagebox variables to see whether they are correct

    • Always make sure you close all brackets and quotes, and don't forget to escape quotes within a string

    • Make sure you use the correct operators and expressions, think about what variables need to be compared or assigned to values

    • First look through your code when it isn't working and try googling it, before you start a thread on any forum.



  • PHP

    • The error "Warning: Cannot modify header information - headers already sent by ..." is caused because you already executed some code before you used the function header() or session_start()

    • When you get an error at the last line of the script or the error Parse error: syntax error, unexpected $end", at 99% of the cases you forgot to close an bracket }

    • The error "Parse error: syntax error, unexpected '"', expecting ',' or ';'" is caused due to the fact you messed up the quotes



  • ASP.NET

    • I personally do not have experience in programming with ASP.NET, if someone that does could write a comment with some tips, I would be happy to add them.


  • (X)HTML


    • Make sure you that you put arguments within events such as onclick='DoSomething("argument1", 3)' with correct quotes

    • Try to indent child elements. Example:

      <ul>
      <li>Text</li>
      </ul>

      Should be:

      <ul>
      <li>Text</li>
      </ul>

    • Use DOCTYPE headers and all other required headers (see http://w3c.org)

    • Always make sure your XHTML passes the W3C validator.


  • MySQL

    • The error "XXX is not a valid MySQL resource" means you screwed up the query

    • If you can't seem to figure out why a query is not working, echo the query and execute it in PHPMyAdmin (this is a musthave!)



  • JavaScript

    • You can use the FireBug add-on to view the (X)HTML generated by JavaScript of a specfic element.

    • I can't say this enough: each JavaScript line must end with a ;

    • Add a alert at the bottom of your script (e.g. alert("Script is working!") ) to make sure that no typo's were made.

    • Put alert's everywhere in your script, to check what code is being executed. If something is not working the alerts after that code will not be executed -> you can isolate the problem



If you have any suggestions for code debugging, post a comment below and I will consider adding them to the guide!
Comments
Latest news
New project: Math Quiz
2010-11-09 18:07:48
Read more...

New project: Custom Messagebox
2010-11-06 19:10:50
Read more...

New project: Visitor Counter
2010-11-01 21:39:04
Read more...

New project: Image Editor
2010-11-01 21:37:27
Read more...

New project: Image Generator
2010-11-01 21:33:05
Read more...

Projects Contact © 2010 WDP - All rights reserved Terms and Conditions Log in