Error connecting to MySQL DB

I have done a lot of development using ASP and MS-SQL. This is my first foray into PHP and MySQL…

First: I am using:
PHP version 5.0.0.0
MySQL version 5.0.45
IIS version 5
Windows XP Pro

Using MySQL admin tool, I:
Set password for root user in MySQL
Created DB and tables
Added a record to one table

I am starting out very simple just to verify I can retrieve from the DB. So I have this line in a php file:
$conn = new mysqli(‘localhost’, ‘root’, ‘pswd’, ‘Testdb’);

I get this error message in the browser:
Fatal error: Class ‘mysqli’ not found in C:SourceCodeTestTest.php on line 11
PHP has encountered an Access Violation at 01F373CD

Here’s what I’ve tried so far:

php.ini:
removed comment for “extension=php_mysql.dll”
Added “extension=php_mysqli.dll” since it wasn’t there
tried various values for “extension_dir” setting; currently at default value of “./”

files:
Added c:php and c:phpext to path
copied dlls from c:phpext to c:php (where php.exe and libmysqli.dll are located)

I restart the IIS service after every change, assuming the php.ini values are only read the first time each browser session. Any suggestions are appreciated…

fond this in the php manual:

Note: For connecting to MySQL 5, it is recommended to download binaries from » http://dev.mysql.com/downloads/connector/php/.

btw: have u thought about switching to apache? because apache/MySQL/PHP (amp) is a that often used combination, so they are known to work.

Thanks for the info. I updated the DLLs, but it didn’t help. I was expecting the ZIP file for the php_mysqli.dll to have a corresponding updated libmysqli.dll, but it had an updated libmysql.dll. Strange…

I’d rather not have to deal with learning Apache too while I am trying to learn PHP and MySQL. I would expect that this should work on IIS - I can’t be the only one trying to run with this configuration.

i never used ISS so im not gonna be a big help if the problem lies there.

have u tryed to run php vrom the console, to find out whether it a php or a ISS problem?

I got the followng errors trying to run it by hand:

  • The procedure entry point _zval_copy_ctor_func could not be located in the dynamic link library php5ts.dll
  • PHP Startup: Unable to load dynamic library ‘C:phpextphp_mysql.dll’ - The specified procedure could not be found.
  • The procedure entry point _zend_std_get_constructor could not be located in the dynamic link library php5ts.dll
  • PHP Startup: Unable to load dynamic library ‘C:phpextphp_mysqli.dll’ - The specified procedure could not be found.

So I deleted it, downloaded the latest build from php.net, and reinstalled. After some very minor tweaking it now works!!

Try this connection string

[php]
connection = mysql_pconnect(hostname, username,password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db(database,connection);
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service