Connection of the Database to the 000webhost

Asked

Viewed 5,456 times

1

I’m having a problem connecting to 000webhost

The code I have is: I think I’m fine because I just changed the values you matched to the localhost

<?php

    ob_start();

        $link = mysql_connect('planos.comla.com', 'a9046774_planos', '') or die('Could not con: ' . mysql_error());
    //$link = mysql_connect('localhost', 'root', '') or die('Could not connect: ' . mysql_error());

    mysql_select_db('a9046774_planos') or die('Could not select database: ' . mysql_error());
    mysql_set_charset('utf8');


?>

And when I put this file in 000webhost appears me this error message

Could not con: Access denied for user 'a9046774_plans'@'10.1.1.23' (using password: NO)

  • Puts the code and connection strings in the question.

  • What do you mean? ?

  • I updated my answer with a code that I found on the internet of a person informing that it got this way. Changes the data to your case.

  • Puts the host as localhost and also the password used to access this server.

1 answer

0

The right way to connect is like this:

<?php
$servername = "Localhost"; ***/* LETRA INICIAL MAUIUSCULA*/***
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>

I found this code on the internet, I believe I can solve your problem. You are not using password and servername is wrong. View your user password and put the servername like this:

$conn = mysql_connect("mysql#.000webhost.com", "a3367xxx_test","******") or die(mysql_error());
  • Friend help is good But it doesn’t work in mine I don’t know why

  • 1

    Have you figured out your password yet? I find it difficult for a bank on the server not to have a password.

  • yes yes but I think the error is not from there

Browser other questions tagged

You are not signed in. Login or sign up in order to post.