


What should I do if an error occurs when php connects to mysql database?
The solution to the error when php connects to the mysql database is: 1. Open the environment variable settings and add the php installation directory after the Path variable; 2. Restart the computer; 3. Copy the libmysql.dll file to the apache server In the bin directory; 4. Restart the apache server.
Error description:
(Recommended tutorial: php tutorial)
PHP connection mysql database When, the following error occurs: Fatal error: Call to undefined function mysql_connect() in.......
Analysis:
This error usually occurs when PHP, Mysql, and Apache servers are configured.
The solution is as follows:
It can be solved by modifying the environment variables.
The specific operation is:
1. Right-click "My Computer", click "Properties", "Advanced", "Environment Variables";
2. Edit the "Path" variable under "System Variables" and add ";E:\php\php5;E:\php\php5\ext" after the original value. ("E:\php\php5" is the installation directory of php)
3. Restart the computer;
4. Copy libmysql.dll in the php installation directory to the bin directory of the apache server Below;
5. Restart the apache server.
Test: test.php
Where user is the username of MySQL, userpassword is the corresponding user password of MySQL
<?php $link=mysql_connect('localhost','[user]','[userpassword]'); if(!$link) echo "fail"; else echo "success"; mysql_close(); ?>
Save the test code in the htdocs of the apache installation directory Next, after starting the server, enter "http://localhost/test.php" in the browser. If "success" appears, it means that PHP has successfully connected to the database.
The above is the detailed content of What should I do if an error occurs when php connects to mysql database?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor
