Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14318 reviews 1707 hosting providers

Questions & Answers

Creating Config file to edit MYSQL

Feb 12, 2013 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 votes
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