#native_company# #native_desc#
#native_cta#

Getting MySQL to Work with PHP

By Suneel Kanuri
on December 29, 2003

To get MySQL to work with the PHP 5 copy /dll/libmySQL.dll to the directory where php 5 resides and copy the /extensions/php_mysql.dll to the directory where php.exe resides.(if you can’t find the two above files probably you are using an old release of PHP 5. You should check for latest at: <a href=”http://snaps.php.net/” target=”_blank”>http://snaps.php.net/</a>)

In additon uncomment extension line in php.ini and add the following code to a gnereal database file(dbcon.php) in my case and include it in each file which needs access to database.


if (!class_exists('mysql')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_mysql.dll');
else
dl('php_mysql.so'); 
} 

I tried to eliminate above code and leave php_gtk.dll in extensions directory. But it didn’t work shouting the familiar dialouge: Unable to load ……

The Other way around is using ODBC driver for MySQL which can be downloaded from:

<a href=”http://www.mysql.com/downloads/api-myodbc-3.51.html” target=”_blank”>http://www.mysql.com/downloads/api-myodbc-3.51.html</a>

and remember PHP requires a system DSN.

For *nix users you need to link the PHP to a driver manager library at configure and compile time. You can obtain an ODBC driver manager from OpenLink Software(LGPL/BSD Licenses) from

<a href=”http://www.iodbc.org” target=”_blank”>http://www.iodbc.org</a>

So good luck coding..

Suneel Kanuri
[email protected]
07/08/2003