Creating Config file to edit MYSQL

asked Feb 12, 2013 in Database by rooby

I want  to create a config file to be able to edit MYSQL connection information to my online database. How can I do this? Please advice?

1 Answer

0 like 0 dislike
answered Feb 12, 2013 by tareq101
Create a file called config.php . This file should contain all define variables, and then you should do the actual connection in your main file. something like this:

  $dbHost = 'yourlocalhost';
  $dbUser = 'youruser';
  $dbPass = 'yourpass';
  $dbName = 'yourdbname';


  if (!$con = mysql_connect($dbHost, $dbUser, $dbPass)) {
    die('Cannnot connect: ' . mysql_error());
  if (!mysql_select_db($dbName, $con)) {
    die(‘Cannot select database');

  // the rest of your code