Database connection to 000webhost [closed]

1

I'm having a problem connecting to 000webhost

The code I have is the following: I think it's fine because I just changed the values corresponding to 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 this error message appears to me

  

Could not with: Access denied for user 'a9046774_planos'@'10.1.1.23' (using password: NO)

    
asked by anonymous 25.11.2015 / 21:48

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 a password and the servername is wrong. View your user's password and put the servername like this:

$conn = mysql_connect("mysql#.000webhost.com", "a3367xxx_test","******") or die(mysql_error());
    
25.11.2015 / 22:00