Little bit vexed here. My script in its current form will not run.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in line : $row=mysqli_fetch_array($result);
This is a snippet from my login script that I am working on at the moment.
if(isset($_POST['submit'])){
$user=$_POST['user'];
$password=$_POST['password'];
//To ensure that none of the fields are blank when submitting the form if
if(isset($_POST['user']) && isset($_POST['password']))
{
$user = stripslashes($user);
$password = stripslashes($password);
$db1=new dbmember();
$db1->openDB();
$sql="SELECT * FROM users WHERE username='{$user}' AND password='{$password}''";
$result=$db1->logcon($user, $password);
$row=mysqli_fetch_array($result);
And this of course is the function that I make calls to :
function logcon($user, $password )
{
$esc_user = mysqli_real_escape_string($this->conn, $user);
$esc_password = mysqli_real_escape_string($this->conn,$password);
$sql = "select * all from users where username ='{$user}' AND password='{$password}";
$result = mysqli_query($this->conn, $sql);
if ($result) {
$numofrows = mysqli_affected_rows($this->conn);
return $numofrows;
}
else
$this->error_msg = "could not connect";
return false ;
So obviously logcon does not return a result set so I can't use mysqli_fetch_array on something that is not a result set. What do I need to be writing? What I don't get is I took this function code from one of my update functions and it worked OK, no problems with returning data.