Is there any alternative to PHP's mysql_connect command?

2

It was all working fine until apparently the installation of Nginx say that my command mysql_connect had the following problem:

  

Warning: mysql_connect () [function.mysql-connect]: Headers and client library minor version mismatch. Headers: 50173 Library: 50536 in / home / tal tal tal

    
asked by anonymous 30.10.2014 / 16:53

2 answers

4

Yes, the PDO.

<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
?>

link

But this error happens when the php version and the mysql libraries are different.

Or you upgrade PHP and recompile it or mysql.

You can try installing / updating php5-mysqlnd.

Just for the record, this is a warning . Your application will not stop working.

PHP is warning that the native php and dp mysql libraries are in different versions.

Important note is that mysql_connect is deprecated . Today, by PHP guidance, you must use either the PDO or mysqli_connect

    
30.10.2014 / 17:14
3

I also recommend using the PDO because your DAL layer does not depend on which version of the database to use, but one day you can migrate your application to POSTGRE, MSSQL ...

Anyway, another alternative is to use Mysqli_connect ():

$link = mysqli_connect("host","usuario","senha","db");

Source:

  

link

    
30.10.2014 / 17:29