I have been building a website with PHP functionality in XAMPP, and everything works perfectly within the localhost. Although, I know that in order to have the same functionality on a live hosted server I will need to change the server info in my config.php file that is used:
<?php
define('ROOT_URL', 'http://localhost/newkellumws/');
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', 'austink01');
define('DB_NAME', 'kellumws');
I've tried changing the DB_HOST to my hosting profile's nameserver, but that did not work. Any help is much appreciated and thank you for your time. I apologize if the is a newbie question...
Assuming you are also moving the site as well the hostname will remain as localhost (as is the case with most shared hosting)
Assuming it's cPanel hosting you will first need to create the database. You can then create an SQL account and grant it access to the DB (recommended) or use your cPanel credentials (Not Recommended)
So your config would look something like this:
define('ROOT_URL', 'http://example.com/newkellumws/');
define('DB_HOST', 'localhost'); // Website and SQL ruinning on the same server
define('DB_USER', 'exampl_kellumws');
define('DB_PASS', 'aBc*63oie8wfq');
define('DB_NAME', 'exampl_kellumws');
See https://documentation.cpanel.net/display/68Docs/MySQL+Databases
if the site is still going to be run via XAMPP (For whatever reason) you would also need to allow Remote MySQL
See https://documentation.cpanel.net/display/68Docs/Remote+MySQL
So your config would instead look something like this:
define('ROOT_URL', 'http://example.com/newkellumws/');
define('DB_HOST', 'c01.example.host'); //Address the SQL Server
define('DB_USER', 'exampl_kellumws');
define('DB_PASS', 'aBc*63oie8wfq');
define('DB_NAME', 'exampl_kellumws');
If you still have issues, contact your hosting provider as they will know the server setup and requirements.
You can also create testConnection.php with the following to help diagnose errors
<?php
require_once('path/to/file/with/config.php');
//Step-1 : Create a database connection
$connection=mysql_connect(DB_HOST,DB_USER,DB_PASS);
if(!$connection) {
die("Database Connection error: " . mysql_error());
}
//Step-2 : Select a database to use
$db=mysql_select_db(DB_NAME,$connection);
if(!$db) {
die("Database Selection error" . mysql_error());
}
echo('Connected to Database');