My database works fine when it runs on my mac on localhost. But when I upload the code with filezilla online, the following warning occurs:
"Warning: mysqli::__construct() [mysqli.construct]:
(HY000/1045):Access denied for user 'root'@'localhost' (using
password: YES) in /users/hassib/www/markme/index.php on line 248
Access denied for user 'root'@'localhost' (using password: YES)
The server I put the code on is hassib.bplaced.net. This is the code on line 248, which works fine on my mac on localhost.
$db = new mysqli('localhost','root','12345','markme');
if($db->connect_error):
echo $db->connect_error;
endif;
Why does it work on my pc, but not when I upload it?
3
Answers
first create database on live(online) and create user with username & password and add user for this database then provide this username & Password to mysqli() function
From the error message above, it seems you are trying to connect with
root
user and nothassib
CREATE DATABASE markme;
hassib
on your server.GRANT ALL PRIVILEGES ON markme.* TO 'hassib'@'localhost' IDENTIFIED BY '12345';
Are your sure that
localhost
is the correct host for your hosting provider? Some providers can provide another hosts for connection. Please, ask your provider for correct host.