Jump to content

Notice: Use of undefined constant


soma56

Recommended Posts

I'm attempting to learn how to connect PHP with MySQL. The sample materials I'm learning from don't have any display issues, however, when I run the code I receive the following error:

 

Notice: Use of undefined constant db - assumed 'db' in C:\mypath\databases.php  on line 4

 

My code is relatively simple and I should note that I'm completely new to learning this stuff.

 

<?PHP
//1. Create a database connection
$db = mysql_connect("localhost", "root", "mypassword");
if (!db) {
	die("Database connection failed: " . mysql_error());
}
?>

 

Suggestions?

Link to comment
https://forums.phpfreaks.com/topic/204580-notice-use-of-undefined-constant/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.