简体   繁体   中英

PHP 5.4 development server doesn't recognize mysql_connect()

I am trying to use the new development server in PHP 5.4. It runs phpinfo() just fine but on my site code and also phpMyAdmin.php they are throwing the following error:

Call to undefined function mysql_connect()

They are running through localhost:8000

php -m is showing that mysqlnd is loaded but that maybe not enough.

The OS is Windows 7

Any thoughts?

mysqlnd is the library that can be used since PHP 5.3, instead of libmysql , by 3 PHP extensions :

  • mysql , which provides the mysql_* functions,
  • mysqli , which provides the mysqli_* functons,
  • and pdo_mysql , which allows one to use PDO with a MySQL database.

mysqlnd by itself doesn't export any function you can use from your PHP scripts : it only provides MySQL connectivity to those 3 extensions -- which are the ones that export functions you can use.


If you want to use the mysql_* functions, you have to make sure that the mysql extension is enabled , with something that whould look like this in one of the .ini files parsed by PHP :

extension=mysql.dll


As a sidenote : the mysql_* functions should not be used anymore, especially for new projects : the mysql extension is old, and doesn't allow one to use recent (well, not that recent anymore, actually) features of MySQL.

Instead, you should be using mysqli or PDO.

It's because register_globals is no longer included as of PHP5.4, in earlier versions it was deprecated and you could force it on. The reason is because it would leave huge security gaps for hackers to exploit.

try install missing mysql module

sudo apt install php-mysqli

check if extension=mysql.so is set in php.ini after installation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM