Mysql connecting

Hi,

I want to create a simple form to input data to a SQL database. I’m using PHP 7 now. I always get an error that I cannot make a connection.
I use 12345678 as my password here instead of the numeric password I really use.

<?php define('DB_NAME', 'epiz_29974600_cathramail'); define('DB_USER', 'epiz_29974600'); define('DB_PASSWORD', '12345678'); define('DB_HOST', 'sql210.epizy.com'); $link = new mysqli('sql210.epizy.com', 'epiz_29974600', '12345678' ); if (!$link) die('Could not connect.'); if ($link) echo('Connected.'); $db_selected = mysqli_select_db($link, DB_NAME); if (!$db_selected) die('Cannot enter.'); if ($db_selected) echo('Entered.'); $value = $_POST['input1']; $sql = "INSERT INTO demo (input1) VALUES ('$value')"; if (!mysqli_query($sql)) die('Input error.'); mysqli_close($link); ?>

This gives me the error:
Warning : mysqli::__construct(): (HY000/1045): Access denied for user ‘epiz_29974600’@‘myipaddress’ (using password: YES) in /home/vol15_6/epizy.com/epiz_29974600/htdocs/signup.php on line 9
Connected.
Warning : mysqli_select_db(): Couldn’t fetch mysqli in /home/vol15_6/epizy.com/epiz_29974600/htdocs/signup.php on line 18
Cannot enter.

To connect to the database, I can suggest using this code to do that:

<?php
define("DBHOST", "your database host");
define("DBUSER", "your database user");
define("DBPASS", "your database password");
define("DBNAME", "your database name");

$conn = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
if(mysqli_connect_error()){ echo "Connection failed: ".mysqli_connect_error(); }
?>

overwriting all details to your database details. And also, the database password is the hosting account password, that can be found by logging into your Client Area, selecting your hosting account, scrolling down to “Account Details” and clicking on “Show/Hide” to show the password.

1 Like

I am still getting the error (see below).
I use the password that you can see in the little ‘show’ window from my ‘Account details’.
For the other information, I look at ‘MySQL Databases’ where I find MySQL DB Name, MySQL User Name and MySQL Host Name in the table.

Warning : mysqli::construct(): (HY000/1045): Access denied for user 'epiz…'@‘192…’ (using password: YES) in /home/vol15_6/epizy.com/epiz_2…600/htdocs/signup.php on line 5
Connection failed: Access denied for user 'epiz
…'@‘192…’ (using password: YES)
Warning : mysqli_query() expects at least 2 parameters, 1 given in /home/vol15_6/epizy.com/epiz_…/htdocs/signup.php on line 14
Input error.

Did you altered your cpanel info?

Like Did you changed your cpanel password?

2 Likes

I tried many things to make it work. I let it produce a random password, didn’t work. Then I changed it to a password with just nine numbers, but as you see that also gives an error.

There is a bug that doesn’t let you use the new hosting account password on the database with MyOwnFreeHost’s API. I think you may need to wait for the Admin to reset the password for your databases, or also to let us know more about that issue.

1 Like

I see, that will probably be the problem. I believe I’ll have to wait for a password reset from the admin then.

I’m resetting your database credentials now. Please check again in 15 minutes or so.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.