mysqli rows and class mysqli not found

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Aug 05, 2017 9:36 am

Sat Aug 05, 2017 9:43 am

So my code as follows always returns
if i test run it with php desinger8 i get
fatal error line 10 fatal error:class 'mysqli' not found in c:\xampp\htdocs\Monsters.php on line 10

and if i access it via my web browser i get

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\PHP\Monsters.php on line 16

what i really need to know at this point is if my script is correct or not so i can troubleshoot elsewhere if its not the script
sqli is most definitely installed and enabled i have another script for account creation where it works perfectly.
for anyone curious i use xampp with apache

Code: Select all

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "accounts";
$conn = new mysqli($servername, $username, $password, $dbname);
if (!$conn)
        die('Could not connect: ' . mysqli_error());
$Monster = "SELECT ID, Monster, XP, FROM 'creature'";
$result = mysqli_query($conn,$Monster);
if(mysqli_num_rows($result) > 0){
    while($row = mysqli_fetch_assoc($result)){
    echo "ID: ".$row['ID']. "Monster: ".$row['Monster']. "XP: ".$row['XP']."<br>";

Post Reply