-3

I'm new to php ,trying to solve my issue(connecting with database at line 12) over here please help...!! seen similar questions over here but they haven't helped me..!! my code is as follows:

<?php 
session_start();

// variable declaration
$username = "";
$password ="";
$db='register';


// connect to database
$db = mysqli_connect('localhost', '$username','$password', 'register') or die("unable to connect");
?>
Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74

1 Answers1

0

The problem is with your quotes. Single quotes don’t expand variables so the username is sent as $username as the error shows. You need double quotes to expand, or in this case no quotes because you just want to pass the values from the variables:

$db = mysqli_connect('localhost', $username, $password, 'register') or die("unable to connect");
Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74