Unable to connect to the database.

Status
Not open for further replies.

rentalcl

New Member
Messages
2
Reaction score
0
Points
1
when i try to connect to the database i have these error.
"ect(): (28000/1045): Access denied for user 'rentalcl_'@'localhost' (using password: YES) in /home/rentalcl/public_html/server.php on line 10"

Orginally, i created everything MAMP, but i then i want to host my website online. so chose this hosting website. so i basically uploaded every file into this web hosting. Ih ave provide first couple of lines. please help me out.

<?php
session_start();
// variable declaration
$username = 'rentalcl_';
$password = 'x';
$database = 'rentalcl_registration';
$host = 'localhost';

// connect to database
$db = mysqli_connect($host, $username, $password, $database);


sincerely,
siva
 
Last edited:

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
please help me out
-
Before being able to use MySQL, you should create a MySQL database and user through cPanel. Then you need to configure your script to connect to MySQL

to configure your script to connect to MySQL - the following settings should be used:

Host/Server Name -> [ localhost ]

Port -> [ 3306 ] (not necessary)

Username -> Your cPanel username followed by an underscore (i.e. "_") and the MySQL username you configured in cPanel

Password -> The password that you used when creating the MySQL user in cPanel

Database -> Your cPanel username followed by an underscore (i.e. "_") and the name of the database that you created in cPanel

Remember: Free hosting accounts do not have remote MySQL access.
###
 

rentalcl

New Member
Messages
2
Reaction score
0
Points
1
I did that, i just upload part of my scrip. but it still saying "Warning: mysqli_connect(): (28000/1045): Access denied for user 'rentalcl_'@'localhost' (using password: YES) in /home/rentalcl/public_html/server.php on line 10"

<?php
session_start();
// variable declaration
$username = 'rentalcl_';
$password = 'x';
$database = 'rentalcl_registration';
$host = 'localhost';

// connect to database
$db = mysqli_connect($host, $username, $password, $database);

// if the REGISTER button is clicked
if (isset($_POST['register'])) {
// receive all input values from the form
$username = mysqli_real_escape_string($db, $_POST['username']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$password_1 = mysqli_real_escape_string($db, $_POST['password_1']);
$password_2 = mysqli_real_escape_string($db, $_POST['password_2'
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
SB - Username -> Your cPanel username followed by an underscore (i.e. "_") and the MySQL username you configured in cPanel
-
your post says your username is --> $username = 'rentalcl_';
###
 
Status
Not open for further replies.
Top