-2

I get this message if i run my register.

<?php
$connection = mysqli_connect('localhost', 'root', 'user'); 
if (!$connection){
    die("Database Connection Failed" . mysqli_error($connection));
}
$select_db = mysqli_select_db($connection, 'test');
if (!$select_db){
    die("Database Selection Failed" . mysqli_error($connection)); 
}
?>
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35

1 Answers1

1

Try this if you don't have a password :

$connection = mysqli_connect('localhost', 'root', '', 'test'); 

// OR with a P@$$w0rd

$connection = mysqli_connect('localhost', 'root', 'P@$$w0rd', 'test');

mysqli_connect takes four parameters:

  1. Database host (if this is a local machine that will be "127.0.0.1" or "localhost"
  2. Database username (local machine will be "root")
  3. Database password (local machine will be "")
  4. Database name (this is to save having to call mysqli_select_db)
JustCarty
  • 3,839
  • 5
  • 31
  • 51
teeyo
  • 3,665
  • 3
  • 22
  • 37