I wrote some function used by a php webpage, in order to interact with a mysql database.In total I have 5 similar php pages. When I test them on my local server everything works fine. the data is populated in mysql DB. but when I host it on the web server, 3 out of my php files shows "Could not connect: Access denied for user 'root'@'localhost' (using password: YES)". whereas the other 2 files are executed as expected. I am using phpmyadmin and I'm hosting the site through cpanel. Could someone help me out with this problem?
The following is the code for one my php file that throws the error
<?php
session_start();
define ('DB_NAME', 'roze');
define('DB_USER', 'root');
define('DB_Password', 'good');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_Password);
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected)
{
die('Cannot use' . DB_NAME . ': ' . mysql_error());
}
echo 'Connected Successfully';
$value4 = $_POST['couch_table'];
$sql = " UPDATE master set couch_table= '".$value4."'";
if (!mysql_query($sql)){
die('Error: ' . mysql_error());
}
header('location: room.html');
?>
Additional info: I have created my FTP and uplaoded my files through Filezilla.