SQL and MySQL Debugging Techniques

The most common SQL errors are caused by the following issues:

  • Unbalanced use of quotation marks or parentheses

  • Unescaped apostrophes in column values

  • Misspelling a column name, table name, or function

  • Placing a query’s clauses (WHERE, GROUP BY, ORDER BY, LIMIT) in the wrong order

    Furthermore, when using MySQL you can also run across the following:

  • Unpredictable or inappropriate query results

  • Inability to access the database

  • Difficulty starting MySQL

When creating Web applications in PHP, the best way to determine the SQL or MySQL issue at hand is to use the mysql_error() function, as introduced in Chapter 6, “Using PHP and MySQL.” In the next sequence of steps, I’ll cover another method for solving SQL and MySQL mistakes. ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.