Hello Everyone

I am using this service 000webhosting.com to host my website. When I tried to connect to the database. I got this error

Could not connect to the database a7848759_lumos :SQLSTATE[28000] [1045] Access denied for user 'a7848759_fareedh'@'10.1.1.13' (using password: NO)

This is my code below

`<?php
`    $host = 'mysql1.000webhost.com';
`    $dbname = 'a7848759_lumos';
`    $username = 'a7848759_fareedh';
`    $password = '';
`try {
`   $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
`    echo "ITS WORKING!!";
`} catch (PDOException $pe) {
`    die("Could not connect to the database $dbname :" . $pe->getMessage());
`}

`?>`

Helppp...THANKS

Are you sure that the database URL for $host is really that one? I doubt it is correct. The $host value is NOT the domain name, but it must be the database URL. The easiest way is to use the IP address. You need to check with your host for the real URL for database.

PS: NEVER post real user name, password, or even database name! You should change the user name now even though you change the password from empty to something else!

Yh, I will change it. I am just going to create a new user. The host name is mysql1.000webhost.com. MySQL host: mysql1.000webhost.com. That is the information displayed next to the username and password in my account

Member Avatar for diafol

This error usually arises when you don't have permission to access the db. I'm assuming that you copied the local db into the hosted db with phpmyadmin or something similar.

I would be very surprised if you had a remote db that did not have a password. Remember that only the data is copied when you import data - not permissions. If you don't get any joy, use phpmyadmin to create a new user and then use those credentials in your php scripts.

No, I created the database on the 000webhosting.com. I also created the username and the password for the databases. I am using the phpMyAdmin provided by the hosting company. Hence, I had to create a new username and password on the PhpMyAdmin and using those credientials in my connect.php

Member Avatar for diafol

Yes but you had this in your message:

(using password: NO)

So I'm assuming that you forgot to include it in $password

OHH GODD!! THAT WAS SOO STUPID OF ME!! THANKK YOUUUU!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.