anmol dubey
Member
I have created a table in xenforo database and now i want to insert some values into the table via a php file which is kept at xenforo home directory. I am currently creating connection everytime the php file is called as below
<Rest of the code to insert values in table>
Is there a better way to connect to the database?
I am just starting with devlopment hence such a naive question
$con = mysql_connect("localhost","XXXXX","YYYYY");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("XXXX",$con);
if (!$db_selected)
{
die ("Can\'t use test_db : " . mysql_error());
}
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("XXXX",$con);
if (!$db_selected)
{
die ("Can\'t use test_db : " . mysql_error());
}
<Rest of the code to insert values in table>
Is there a better way to connect to the database?
I am just starting with devlopment hence such a naive question