0

okay guys so i was just writing the code for an admin panel just for fun, and i ran into a problem when i copied some code from w3schools. Can someone tell me where i am wrong.

Here's My Code

    <?php
  $conn = mysql_connect("localhost", "root","","ATFlogin");
$sql = "SELECT id, username, password FROM users";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

    while($row = $result->fetch_assoc()) {
        echo "<br> id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] . "<br>";
    }
} else {
    echo "0 results";
}
?>

1 Answers1

0

it Looks like you are trying to mix mysql with mysqli.

Change your connection to be:

$conn = mysqli_connect("localhost", "root","","ATFlogin");

Read up on MySQLI here

mysql functions have all been depracted and mysqli is the successor so if possible use mysqli.

James
  • 406
  • 1
  • 3
  • 12