Home > Backend Development > PHP Tutorial > mysql - PHP cli mode to connect to the database

mysql - PHP cli mode to connect to the database

WBOY
Release: 2016-08-18 09:15:29
Original
1811 people have browsed it

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>
Copy after login
Copy after login

Then run the script with cli under putty
mysql - PHP cli mode to connect to the database

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

Reply content:

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>
Copy after login
Copy after login

Then run the script with cli under putty
mysql - PHP cli mode to connect to the database

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template