Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
MySQL version 5, PHP version 5 and mysqli

There's a great deal of code and data that uses MySQL version 3 and PHP version 4 and it works very well. Many users are NOT rushing to upgrade. But MySQL has now progressed on to MySQL version 5, and PHP is at version 5 too. This article considers some of the new facilities offered, and some of the upgrade issues involved.

MYSQL 3 -> 4 -> 5

MySQL version 3 had many years of life as "the current and latest" and was installed on many servers under many different operating systems. A great deal of software was written to make use of it. But times moved on and its "lean, mean and efficient" approach was becoming just TOO lean and mean; people wanted additional facilities that were available in other databases and MySQL at version 3 needed to be enhanced to catch up.

MySQL version 4.0 was described as an "enabling release" - not in itself providing a huge range of new facilities, but rather marking the way forward with a rewrite of much of the internal code. Some of the facilities such as InnoDb tables which used to be optional were rolled in as standard, giving facilities such as transaction handling in the default download / configuration.

At MySQL 4.1, further updates were introduced including a new security / login model that meant that all client programs had to be upgraded to access the data, unless a user account was created with a specifically-stated old style password.

MySQL 5.0 became generally available in October 2005. It adds stored procedures, Triggers, Views, a Data Dictionary and more.

PHP 3 ->4 -> 5

PHP 3 is now ancient history by computing standards. It was very much a structured programming language and it provided an excellent embedded scripting system for web pages.

In PHP 4, an object oriented model was added but being based on some of the older code, that model was good rather than excellent. PHP 4 went through quite a number of releases and there's still the occasional maintenance release. From 4.0 to 4.4, PHP really grew beyond all recognition.

The OO model has been fixed in PHP 5. The fixing of the OO model lead to a specific code incompatibility in relation to the copying of objects; it doesn't effect too many people BUT it was sufficient to require a change in the major release number ... and the opportunity was taken to make a number of other changes at the same time.

THE PHP / MYSQL DRIVER ISSUE

With the new client security model at MySQL 4.1, the MySQL drivers built in to PHP4 will only function if you have old passwords set on an account; if you need to set up such a password, the command you need in MySQL is something like

SET PASSWORD FOR "wwweb"@"localhost"
         = OLD_PASSWORD("paddington")

With the coming of the new security model, the MySQL authors also updated their open source license so that it's no longer compatible with the PHP distribution license, and as a result PHP version 5 doesn't ship with drivers for the current version of MySQL - but it does ship with the older version still if you're happy to use that, and it can be used with modern versions of MySQL if you're prepared to use the OLD_PASSWORD.

Looking forward, PHP now ships with a new class that defines the interface to MySQL - it's known as "mysqli" and that stands for MySQL Improved. It does NOT include the MySQL drivers - remember, it can't due to the licensing issues, but if you build PHP5 on a system on which MySQL 5 is already installed, you can include the recent MySQL drivers from the MySQL distribution. It's a very neat solution to the licensing issue.

MySQL functions with names starting mysql are the old style functions. Functions with names starting with mysqli are the new style functions. The names are NOT simply interchangeable - call sequences vary. If you're writing code in PHP that's to be portable between different database anyway, we suggest you use a wrapper as we teach on our PHP course.

RECOGNISING PROBLEMS

Here are some sample outputs if you get things wrong - the cause isn't always obvious!

1. You're trying to talk to a recent MySQL database using the old style routines, through a login which does NOT have an old style password set.


2. You're trying to use the new style routines in a version of MySQL which has been built with the old style routines, or has no MySQL support at all!


3. You're trying to use the new style routines but with the old sequence of parameters to them


This is what it SHOULD look like:


Original code using mysql functions will work under PHP 5 and MySQL 5 if PHP is built with the mysql drivers AND The MySQL 5 trainee account has the old password set.

Working example - mysql
New code using mysqli functions will work if the PHP has been built to use the new functions on a system on which MySQL had already been installed.

Working example - mysqli

See also MySQL training course

Please note that articles in this section of our web site were current and correct to the best of our ability when published, but by the nature of our business may go out of date quite quickly. The quoting of a price, contract term or any other information in this area of our website is NOT an offer to supply now on those terms - please check back via our main web site

Related Material

MySQL 5 and PHP 5
  [104] - ()
  [494] - ()
  [515] - ()
  [1131] - ()
  [1417] - ()
  [1455] - ()
  [1754] - ()
  [1766] - ()
  [2172] - ()
  [3455] - ()

Using MySQL Databases in PHP Pages
  [104] - ()
  [515] - ()
  [572] - ()
  [581] - ()
  [647] - ()
  [666] - ()
  [723] - ()
  [915] - ()
  [937] - ()
  [947] - ()
  [1010] - ()
  [1561] - ()
  [1983] - ()
  [2071] - ()
  [2259] - ()
  [2320] - ()
  [2432] - ()
  [2447] - ()
  [2561] - ()
  [2628] - ()
  [3035] - ()
  [3455] - ()
  [4378] - ()
  [4483] - ()

Interfacing Applications to MySQL Databases
  [104] - ()
  [644] - ()
  [663] - ()
  [723] - ()
  [1381] - ()
  [1450] - ()
  [1518] - ()
  [1561] - ()
  [1885] - ()
  [2263] - ()
  [2381] - ()
  [2745] - ()
  [2790] - ()
  [3035] - ()
  [3099] - ()
  [3447] - ()
  [3455] - ()
  [4436] - ()

resource index - MySQL
Solutions centre home page

You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum.

At Well House Consultants, we provide training courses on subjects such as Ruby, Lua, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/solutions/mysql-my ... ysqli.html • PAGE BUILT: Wed Mar 28 07:47:11 2012 • BUILD SYSTEM: wizard