MySQL Version Difference

Posted in: Development

If you are running MySQL queries from PHP and include the semi-colon in the SQL query, your query will run just fine on a MySQL 4 database but will fail on a MySQL 3 database.

This doesn’t work in MySQL 3:

$sql = "SELECT * FROM foo;";

but this does:

$sql = "SELECT * FROM foo";

At least this is what I’m seeing, is this a known thing?

Popularity: 2% [?]

Posted July 15th, 2004 @ 11:15 AM

3 Replies

  1. Edward adds this Comment:

    According to the PHP docs: ” The query string should not end with a semicolon.”

    I assume PHP handles/appends a semicolon to the string for you. But why it’s only failing under MySQL 3 puzzles me too. Sorry I can’t help much.

    July 15th, 2004 at 12:40 pm

  2. Lennart adds this Comment:

    yes :-)
    Also I have seen some dbs don’t like a whitespaces in their queries:

    SELECT name, descr FROM table

    won’t work, but

    SELECT name,descr FROM table

    will.

    July 15th, 2004 at 12:41 pm

  3. Alex adds this Comment:

    phpMyAdmin will include the trailing ‘;’ if you tell it to create PHP code, I guess this is a bug.

    July 17th, 2004 at 6:10 pm

Add a Comment

Please note: Use of a non-personal web site or blog in the field below and/or comments that are off-topic, personal attacks, or support requests will likely be removed at my discretion.

Note: This post is over 4 years old. You may want to check later in this blog to see if there is new information relevant to your comment.

Breaking 40 » « Fun Word Definitions

About This Site

This is the personal web site of Alex King, an independent developer based in Denver, Colorado USA. More...


Crowd Favorite

Crowd Favorite is my software and web development business.

We build web applications, design and develop custom WordPress themes and plugins, and build custom sites using WordPress as a CMS.


I also have a tumblog that aggregates my online content from other services (Twitter, Flickr, del.icio.us. etc.).

Ads