Warning: count(): Parameter must be an array or an object that implements Countable in C:\xampp\htdocs\try\process.php on line 30.
That's what my code says. it seems so fine but when I press edit, this error shows. I don't understand. can someone point me out what happened in line 30?
here is my process.php
<?php
require("1password.php");
$id = 0;
$update = false;
$username='';
$password='';
if (!session_id()) { session_start(); }
$mysqli = new mysqli("localhost","root","","id7508046_isalon") or die(mysqli_error($mysqli));
if(isset($_POST['save'])){
$username = $_POST['username'];
$password = $_POST['password'];
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$mysqli->query("INSERT INTO isalonusers (username, password) values ('$username', '$passwordHash')") or die($mysqli->error);
$_SESSION['message'] = "New account saved!";
$_SESSION['msg_type'] = "success";
header("location: userlist.php");
}
if(isset($_GET['delete'])){
$id = $_GET['delete'];
$mysqli->query("DELETE FROM isalonusers WHERE user_id=$id") or die($mysqli->error());
$_SESSION['message'] = "User Account Deleted!";
$_SESSION['msg_type'] = "danger";
header("location: userlist.php");
}
if(isset($_GET['edit'])){
$id = $_GET['edit'];
$update = true;
$result = $mysqli->query("SELECT * FROM isalonusers WHERE user_id=$id") or die($mysqli->error());
if(count($result)==1){
$row = $result->fetch_array();
$username = $row['username'];
$password = $row['password'];
}
}
if(isset($_POST['update'])){
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
$mysqli->query("UPDATE isalonusers SET username ='$username', password='$passwordHash' WHERE user_id=$id") or die($mysqli->error());
$_SESSION['message'] = "User Account has been updated!";
$_SESSION['msg_type'] = "warning";
header("location: userlist.php");
}
?>