Apeshape Posted August 1, 2013 Share Posted August 1, 2013 Hi, basically I have this snippet some of which I am trying to move into a function. In its current form it works OK, but when I try to call for it within my function it does not : Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in C:\xampp\htdocs\1\assets\includes\memberfunc.php on line 18 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\1\login.php on line 106 Acess denied, wrong username or password? Here's the function. 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); $row = mysqli_fetch_array($this->conn, $result); return $row; } Here's the old, working code. 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); if($row[0]==1) { session_start(); $_SESSION['user'] = $user; $_SESSION['password'] = $password; $_SESSION['loggedin'] = "true"; header("location:index.php"); } Any help on this would be fantastic. I'm pretty stuck. Quote Link to comment https://forums.phpfreaks.com/topic/280721-login-function-help/ Share on other sites More sharing options...
litebearer Posted August 1, 2013 Share Posted August 1, 2013 compare your two query strings closely. Do you see ALL the differences? Quote Link to comment https://forums.phpfreaks.com/topic/280721-login-function-help/#findComment-1442991 Share on other sites More sharing options...
Apeshape Posted August 1, 2013 Author Share Posted August 1, 2013 Do you mean the user of upper cases. Does that make a difference? Quote Link to comment https://forums.phpfreaks.com/topic/280721-login-function-help/#findComment-1443047 Share on other sites More sharing options...
boompa Posted August 1, 2013 Share Posted August 1, 2013 No. There's something extra in your new query. Details matter. Quote Link to comment https://forums.phpfreaks.com/topic/280721-login-function-help/#findComment-1443053 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.