Home  >  Article  >  Backend Development  >  PHP connection mysql prompts Call to undefined function mysql_connect()_PHP tutorial

PHP connection mysql prompts Call to undefined function mysql_connect()_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:06:061315browse

Today I configured the php mysql environment in windows. I am very happy to test a piece of code and the result prompts Call to undefined function mysql_connect(), which proves that the database configuration was unsuccessful.

1. Copy the two files libmysql.dll and php5ts.dll in the php folder to system32 in the windows directory; or add D:php;D:phpext to the environment variables. These two directories are the PHP installation directory and the extension dll directory.
The code is as follows
 代码如下 复制代码

$conn = mysql_connect('localhost','root','password');

var_dump($conn);

?>

Copy code

$conn = mysql_connect('localhost','root','password');

var_dump($conn);

?>

 代码如下 复制代码

extension=php_mysql.dll
extension=php_mysqli.dll把前面的分号去掉


Basically change the configuration file php.ini

First make sure extension_dir = "./ext" in php.ini, this setting is the directory where php refers to the dll;
2. Modify php.ini in the windows installation directory and remove the semicolon in front of extension=php_mysql.dll; 3.extension_dir = "d:phpext (the file is in PHP.INI).

Look at the configuration of your php.ini and find it
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn