Database selection faild

please my database selection failed, where could i be going wrong


error_reporting(E_ALL); 
ini_set('display_errors',1);
<?php
	//1.create database connection
	$connection = mysql_connect("localhost","root","password");
	if (!$connection) {
		die("Database connection failed: " . mysql_error());
		}
		//2 select database to use
	$db_select = mysql_select_db("reacheasy","connection");
	if ($db_select) {
		die("Database selection failed: " . mysql_error());
		}
		?>
<?php require_once("include/functions.php"); ?>
<?php include("include/header.php"); ?>
<div id="navigation">
<ul>
<li>
    
    <?php
	//3. perform database querry
	$result = mysql_query("SELECT * FROM subjects", $connection);
	if (!$result) {
		die("Database query failed: " . mysql_error());
		}
		//4 use returned data
	while($row = mysql_fetch_array($result)) {
		echo $row["menu_name"]." ".$row["position"]."<br />";
		}
		?>
	</li>	
</ul>
</div> <!--end of navigation div -->
<div id="bodycontent">
<h3> content area</h3>
<p> i hope this works. </p>
</div>
<?php include("include/footer.php"); ?>
<?php
	//5. close connection
	mysql_close($connection);
	?>

Use $connection instead of "connection" in the line $db_select = mysql_select_db("reacheasy","connection"); :slight_smile:

‘mysql_select_db’ is a boolean function returning TRUE on success. A bang is missing before the variable '$db_select '. The ‘if’ statement should become:


    if ([B]![/B]$db_select) {
        die("Database selection failed: " . mysql_error());


thanks