PHP native(5.6) on the hosting, the whole site works fine. When switching to PHP 5.5 or PHP 7.0 connection to the database is lost (I use mysqli ), there are no errors in error_log . What could be the problem?
$mySQL = mysqli_connect('localhost:3306', 'login', 'password', 'table'); if ($stmt = $mySQL->query("SELECT * FROM `table` WHERE `razd` = 1 ORDER BY RAND() LIMIT 3;")){ while($row = $stmt->fetch_assoc()){ echo $row['article']; } } mysqli_close($mySQL); UPD: Now the error has appeared:
PHP Warning: mysqli_connect (): (HY000 / 2005): Unknown MySQL server host 'localhost: 3306' (2)
The problem is that in phpMyAdmin server is written as localhost:3306 , and whatever variations of mysqli_connect I tried, none of them worked. And the port indicated 5 parameter, and tried all variations of localhost .
if (!$mySQL) die(mysqli_connect_error());- Anton Shchyrovlocalhost, but directly IP127.0.0.1- NTP