10
I have a question that has brought me several incompatibilities. With the evolution of PHP and Mysql, more recent versions have emerged, this way Mysqli. That’s where my problem lies, I would like to know what is the right way to connect.
With Mysql it was:
$con = mysql_connect("localhost","root","");
And with the Mysqli ?
$mysqli = new mysqli("localhost","root","","nome-tabela");
or
$mysqli = mysqli_connect("localhost","root","");
When I look at the PHP manual, there’s a more object-oriented approach, but I’ve never seen it this way.
Both work well. It goes from your style of use. I particularly like the functional model, but it’s just a matter of taste and context, the functionality is identical. And the good thing is that mysqli is very similar to mysql, so the migration from one to another is very simple (even being specialized in Mysql, any alternative is inferior)
– Bacco
Have you considered using PDO? mysql_ are deprecated PHP functions.
– Hiago Souza