Home >Backend Development >PHP Tutorial >mysql - PHP cli mode to connect to the database
cli mode runs php, including the following code:
<code>echo "开始"; $connection=mysql_connect("localhost","root","123456"); mysql_select_db("mydb"); mysql_query("set names utf8"); echo "数据库连完了";</code>
Then run the script with cli under putty
Only the first line of code is printed, and printing after connecting to mysql is not executed.
Excuse me, why is this?
Resolved: The mysql module was not loaded successfully in multiple environments
cli mode runs php, including the following code:
<code>echo "开始"; $connection=mysql_connect("localhost","root","123456"); mysql_select_db("mydb"); mysql_query("set names utf8"); echo "数据库连完了";</code>
Then run the script with cli under putty
Only the first line of code is printed, and printing after connecting to mysql is not executed.
Excuse me, why is this?
Resolved: The mysql module was not loaded successfully in multiple environments
Post the phpinfo output to see? Is your Linux a Debian system?
Please use pdo