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 .

  • In general, the port number is the 5th parameter. That is rather interesting as it works now. - Small
  • In order for the logs to have errors, they need to be written there if (!$mySQL) die(mysqli_connect_error()); - Anton Shchyrov
  • The problem was solved using not localhost , but directly IP 127.0.0.1 - NTP

0