Connect to the database in mysql-PHPcli mode

Source: Internet
Author: User
Run php in cli mode, including the following code: {code ...} run the script in putty and run cli to print only the first line of code. after connecting to mysql, the script will not be printed. Why? Solved: The mysql module is not loaded successfully in multiple environments.

Run php in cli mode, including the following code:

Echo "start"; $ connection = mysql_connect ("localhost", "root", "123456"); mysql_select_db ("mydb"); mysql_query ("set names utf8 "); echo "the database is connected ";

Run the script in putty using cli.

Only the first line of code is printed, and the printing after mysql is connected will not be executed.
Why?

Solved: The mysql module is not loaded successfully in multiple environments.

Reply content:

Run php in cli mode, including the following code:

Echo "start"; $ connection = mysql_connect ("localhost", "root", "123456"); mysql_select_db ("mydb"); mysql_query ("set names utf8 "); echo "the database is connected ";

Run the script in putty using cli.

Only the first line of code is printed, and the printing after mysql is connected will not be executed.
Why?

Solved: The mysql module is not loaded successfully in multiple environments.

Paste a phpinfo output to see it? Is your Linux system Debian?

Use pdo

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.