1. Question:
An error occurred while testing the php7.0 link MySQL database:
Fatal error:uncaught error:call to undefined function mysqli_connect ()
Even if you put a line in/etc/php/7.0/apache2/php.ini:
;extension=php_mysql.dll
Modify to (that is, cancel the semicolon before the line ";") ):
extension=php_mysql.dll
The problem remains unresolved.
Test file:
require_once__dir__. ' /config.php ';//2. Get the user name to query (pass parameters via the address bar)$username=isset($_get[' username '])?$_get[' username ']: ';if(Empty($username)){ Echo' User name cannot be empty. ';}//3. Connect to the database$conn[Email protected]Mysqli_connect($db _host,$db _user,$db _PSW) or die(' Database connection failed. ')Mysqli_error());Var_dump($conn);
config.php file:
<? PHP /* */$db _host= ' 127.0.0.1 '; $db _user= ' root '; $db _psw= ' 123456 '; $db _name= ' Test '; $db _charset= ' UTF8 ';
View Code
2. Effective Solutions:
- sudo apt-get install Php7.0-mysql
- sudo dpkg-reconfigure php7.0-mysql
- Sudo/etc/init.d/mysql restart
- Sudo/etc/init.d/apache2 restart
Last connection succeeded:
Reference: http://blog.sina.com.cn/s/blog_6b8bea470100qrdw.html
Call to undefined Function:mysql_connect () appears in ubuntu16.10 PHP test connection MySQL