Call to undefined Function:mysql_connect () appears in ubuntu16.10 PHP test connection MySQL

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.