I created php script called functions.php in which i've written following codes. It's working fine when i've written "$conn = mysql_connect('localhost','root','pass');" this line. But i want to store these credentials in config file so that it becomes quite easy for me to edit details while working with db. So i created config.php and have written following codes :
<?php
// this is config.php
$config = array(
'host'=> 'localhost'
'username' => 'root' ,
'password' => 'pass' ,
'database' => 'sample'
);
?>
This is functions.php
<?php
include 'config.php';
function connect($config) {
$conn = mysql_connect($config['host'],$config['username'],$config['password']);
return $conn;
}
$con = connect();
if(!$con) die ('problem in connection');
But when i did this then its not working. How can i fix this? Plzz hlp