创建php文件

I have a problem where I can not retrieve the result from my MySQL database (via PHP). I use the same function in other places and it works flawlessly. However at this point i keep getting the "Warning: mysqli_query(): Couldn't fetch mysqli" error.
heres my php code:

<?php
$servername = "localhost";
$username = "root";
$password = "123456";
$dbName = "cool_yt_rpg";

//Make Connection
$conn = new mysqli($servername, $username, $password, $dbName);
//Check Connection
if(!$conn){
   die("Connection Failed."  . mysqli_connect_error());
 }

$sql = "SELECT ID, Name, Type, Cost FROM items";
$result = mysqli_query($conn ,$sql);

if(mysqli_num_rows ($result)){ 
   //show data for each row
      while($row = mysqli_fetch_assoc($result)){
         echo "ID:" .$row['ID'] . "Name:" .$row['Name'] . "Type:".$row['Type'] . "Cost:" .$row['Cost'] . "<br>";
      }
}
?>

and i got this error:

Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\Cool_YT_RPG\ItemsData.php on line 8

Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in C:\xampp\htdocs\Cool_YT_RPG\ItemsData.php on line 15

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Cool_YT_RPG\ItemsData.php on line 17

Looks like $result is coming back null for some reason. You'll want to investigate why.

That said, you could do this so it doesn't crash when that happens:

if(isset($result) && mysqli_num_rows ($result))

And then print some kind of error message in an else block.