如何在PHP中连接mysql服务器 [英] How to connect mysql server in PHP
问题描述
我是PHP的新手。当我尝试使用PHP连接服务器时,获取MySQL服务器已经消失错误。我可以在MySQL工作台中访问具有相同凭据的数据库。所以,凭证没有问题。
代码:
$ servername ='localhost';
$ username ='root';
$ password ='';
$ dbname ='moodle';
$ conn = mysql_connect($ servername,$ username,$ password,$ dbname);
请建议您的解决方案。
我尝试了什么:
谷歌搜索这个错误必须是他们建议设置超时的最大值。我试过那个。但是没有解决。
I am new for PHP.Getting "MySQL server has gone away" error when i try to connect server using PHP. I can able access database with same credential in MySQL workbench. So, there is no problem in credentials.
Code:
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = 'moodle';
$conn = mysql_connect($servername, $username, $password,$dbname);
Please suggest your solution.
What I have tried:
Googling for this error must of them suggest to set maximum for timeout . I tried that one. But not resolved.
推荐答案
servername ='localhost';
servername = 'localhost';
username ='root';
username = 'root';
password ='';
password = '';
这篇关于如何在PHP中连接mysql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!