2

I'm new to PHP and keep getting the above error keep getting this error.

Below is my code

<?php
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'project');

/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, project);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
O Sparks
  • 43
  • 1
  • 9
  • 1
    Possible duplicate of [What does the PHP error message "Notice: Use of undefined constant" mean?](https://stackoverflow.com/questions/2941169/what-does-the-php-error-message-notice-use-of-undefined-constant-mean) – Greg Schmidt Feb 26 '19 at 23:30
  • Possibly you DB_NAME? –  Feb 26 '19 at 23:35

1 Answers1

1

Do this instead. The constant is defined on the left, value on the right. You are trying to call it by value

<?php
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'project');

/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
?>
Ice76
  • 1,143
  • 8
  • 16