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.