Pass variable between PHP files

0

Maybe this question is duplicated, but I have this problem. I took a project to continue here in the service and it uses old functions like mysql_connect, mysql_querry and I need to change this. ex:

mysql_connect("localhost", "root", "",) or die ("Falha ao conectar ao banco de dados - ".mysql_error());

And it used a file with a function to make a connection to the database, and mysql_query does not need to pass a connection as a parameter so it worked, since mysqli_query needs a connection, so every time I'm using it, I have to open a new connection and then close at the end of mysqli_query.

Finally, I wanted to know how to keep this connection file and send this $ con variable to all the files you need. example:

$con = mysqli_connect("localhost", "root", "","db") or die ("Falha ao conectar ao banco de dados - ".mysqli_error($con));
    
asked by anonymous 25.05.2018 / 19:22

0 answers