Soldato
I've finished a site using XAMPP and it all works fine, but upon uploading to the server it doesn't seem to like the way I'm connecting to the database.
On my local machine this works fine, but on the server I get the following errors:
It's not a username/password issue as I can't connect to an old database either. However using a previous connection method - $link = mysql_connect($dbHost, $dbUser, $dbPass); - does work, but then my code later on doesn't work due to the different method.
Any ideas?
Code:
$dbHost = "localhost";
$dbUser = "user";
$dbPass = "password";
$dbName = "name";
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
if(!$mysqli) {
echo "Could not connect to server";
exit;
}
if(!mysql_select_db($dbName)) {
echo "Could not select database";
exit;
}
On my local machine this works fine, but on the server I get the following errors:
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'root'@'localhost' (using password: NO) in /home/etc/index.php on line 17
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/etc/index.php on line 17
Could not select database
It's not a username/password issue as I can't connect to an old database either. However using a previous connection method - $link = mysql_connect($dbHost, $dbUser, $dbPass); - does work, but then my code later on doesn't work due to the different method.
Any ideas?
Last edited: