Description :
I have started using mysqli_* functions before that I was using mysql_* now the mysqli_* requires a variable lets say $con to be passed as aenter code heren argument to the mysqli_* function which contains this;
$con = mysqli_connect("localhost","my_user","my_password","my_db");
Now I have a different page at which I am connecting to the database which is just included at every php page to keep the work going like this;
--------- connect.php----------
<?php
if(!mysql_connect("localhost","root",""))
{
echo "cannot connet to the server";
}
if(!mysql_select_db("katchup"))
{
echo "Cannot connect to the database";
}
?>
and other pages like this
----------- get_products.php -----------
include 'connect.php';
$result = mysql_query("any query"); // this is what I have
$result = mysqli_query($con , "any query"); // this is what I want
My question is how do I get the $con in connect.php in other pages?
$con = mysqli_connect("localhost","my_user","my_password","my_db");this is right way... and if you are creating function for query you just need to callglobal $coninside the function.