For beginners: PDO operations on linux

Source: Internet
Author: User
On the recently applied student machine, I tried to connect to the database on linux: {code ...} however, the webpage cannot be connected, and the status code 500 is returned. the connection is successfully tested on the local host, and the code is correct (account, password, and database are all correct). in the linux host, test: phptest .... I tried to connect to the database on linux for the recently applied student machine:

try {    $conn = new PDO("mysql:host=$server;dbname=$db",$user,$pass);    echo "connection success!";}catch(PDOException $e) {    echo $e->getMessage();}

However, the webpage cannot be connected. the returned status code is 500.
The connection is successfully tested on the local host, and the code is correct (account, password, and database are all correct ),

On a linux host, test:

Php test. php // return connection success!

It's strange, why is the web page a ghost when php commands can be run?
Is there no PDO extension? If yes, how can I install it?

Reply content:

I tried to connect to the database on linux for the recently applied student machine:

try {    $conn = new PDO("mysql:host=$server;dbname=$db",$user,$pass);    echo "connection success!";}catch(PDOException $e) {    echo $e->getMessage();}

However, the webpage cannot be connected. the returned status code is 500.
The connection is successfully tested on the local host, and the code is correct (account, password, and database are all correct ),

On a linux host, test:

Php test. php // return connection success!

It's strange, why is the web page a ghost when php commands can be run?
Is there no PDO extension? If yes, how can I install it?

In most cases, the mysql User permission is incorrectly set and can be accessed locally, whereas the access is denied by the route.

$serverIf yes"localhost"You can change it"127.0.0.1"Try? The two are different.

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.