Access to an external Database
-
Hi. I created a website for a basketbal team. In order to manage results, players, different information, related to diffent seasons and different leagues, I use an external database (MySQL) with PHP code. I am very happy with the woody solution and currently there are almost 66 scripts (PHP or Universal)
For accessing to the database I actually have to put the parameters (Host, DB, User and PW) directely in quite each script.
Now there are two kind of issues:
1) should I hide the parameters for protecting my data?
2) should I create a small snippet just for the access to the database like$servername = "*********";
$user = "user";
$password = "*************";
$dbname = "*******";// Create connection
$conn = @mysqli_connect($servername, $user, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Connessione fallita: " . die (mysqli_connect_error());
}
or just$servername = "hostingmysql01.register.it";
$user = "SP4273_user";
$password = "SPa92113";
$dbname = "spiox_com_campionati";// Create connectionShould I manage the execution of a sequence of three snippets?
[wbcr_php_snippet id=”xxxx1″ title=”access_param”]
[wbcr_php_snippet id=”xxx99″ title=”main” mysquadra=”abcdef”]
[wbcr_php_snippet id=”xxxx2″ title=”close_db”]
Thanks
You must be logged in to reply to this topic.