David
David

Reputation:

Can't send PHP query to MySQL

When i'm trying to send query from PHP 5.4.6 TS,VC9 to MySQL 5.5 (NTS,VC9) I get the message:

 Fatal error: Call to undefined function mysql_connect()

after restarting Apache 2.2 on (Windows xp) it says:

PHP Startup: mysql: Unable to initialize module
Module  compiled with build ID=API20100525,NTS,VC9
PHP     compiled with build ID=API20100525,TS,VC9
These options needs to match

How can I solve this issue?

Upvotes: 1

Views: 218

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562270

You probably installed PHP 5.4 without the package for mysql support. In some distributions of Linux, the PHP mysql extension is in a separate package.

For example, on my CentOS VM I have these packages installed:

$ rpm -qa | grep php
php55w-common-5.5.0-1.w6.x86_64
php55w-pear-1.9.4-6.w6.noarch
php55w-cli-5.5.0-1.w6.x86_64
php55w-mysql55-5.5.0-1.w6.x86_64
php55w-5.5.0-1.w6.x86_64
php55w-pdo-5.5.0-1.w6.x86_64

As for how to resolve this error, it depends on what distro of Linux you're using, and what's the package repo from which you're installing PHP.

PS: You shouldn't be using the deprecated mysql_* extension at all, unless you need to support legacy PHP code. Use mysqli or PDO.

Upvotes: 4

Related Questions