PHP 5.6 with Mysqli_connect

2019-06-26 02:24发布

We recently updated PHP to the latest version, and we had a php script that was running that is now broke.

Currently, it is not even allowing me to connect to the SQL database at all, and is returning this error: "Failed to connect to MySQL: Can't connect to MySQL server on mysql01.fau.edu (13) 2003".

The database itself is located in a linux environment and I currently cannot get even a simple script as the one below running:

$host = 'mysql01.fau.edu';
$username = '*****';
$password = '*****';
$database = '******';
$connect = mysqli_connect($host,$username,$password,$database);

if (mysqli_connect_errno()) {
    echo 'Failed to connect to MySQL: ' . mysqli_connect_error() . mysqli_connect_errno();
} else {
    echo 'Connected to MySQL! </ br>';
}

Any help would be greatly appreciated. Thank you!

3条回答
闹够了就滚
2楼-- · 2019-06-26 03:18

Just guessing...but check to make sure you can connect to mysql from the command line. If so...double check your php.ini. Sounds like php.ini may have been overwritten with the upgrade. Make sure you have the extensions for mysql enabled.

查看更多
劫难
3楼-- · 2019-06-26 03:24

mysqli connect stopped working from version 5.5 upwards, from php 7 updwards, it was removed and will give you a http ERROR 500 refer to the link below

"Call to undefined function mysql_connect()" after upgrade to php-7

查看更多
三岁会撩人
4楼-- · 2019-06-26 03:25

For security purposes Mysql is not remotely accessible by default, unless you whitelist the allowed IP in the backend.

You have mentioned it used to work on your laptop which could very possibly change IP.

Use the same network when it was working

查看更多
登录 后发表回答