This article uses the mysql_connect function of php to connect to the mysql database. The precondition is that the extensionphp_mysql in php. ini should be removed from the previous ";". the code is as follows :? Ph... this article uses the mysql_connect function of php to connect to the mysql database. in ini; extension = php_mysql, remove the previous ";". the code is as follows:
Connect to and select a database. the code is as follows:
In this way, you can connect to the database. if you encounter problems, the following code appears: Call to undefined function 'MySQL _ connect ()'... Failed. the prompt "function undefined" indicates that the mysql_connect () function is not available.
The solution is as follows:
Run php_mysql.dll and libmysql. copy the dll file to c: winntsystem32 (I missed libmysql. dll), find php. in ini; extension = php_mysql, remove the previous ";" restart the server.
Now everything is ready. now we have a simple connection instance. for example 1, the code of the conn. php file is as follows:
The index. php file code is as follows:
// Display data content:
In this way, we implement a simple php mysql connection and query the data we need.
Article address:
Reprint at will ^ please include the address of this article!