php - While loging in i am trying to validate values from 3 tables, but not working? -


i getting these errors:

warning: mysql_query() expects parameter 1 string, object given in h:\xamp\htdocs\newlogintry.php on line 12

warning: mysql_query() expects parameter 1 string, object given in h:\xamp\htdocs\newlogintry.php on line 13

warning: mysqli_num_rows() expects parameter 1 mysqli_result, null given in h:\xamp\htdocs\newlogintry.php on line 18

but php code wrote it, want check whether "type" of account either teacher account or pupil account if among them pass main page respective type parameter, please tell me if usage of php right since new it, here php code(newlogintry.php)

<?php $start=1; $username=$_get['username']; $password=$_get['password'];  $con=mysqli_connect("localhost","root","","repute system");     if(mysqli_connect_errno()){         echo "error ".mysqli_connect_error();     }          //$result = mysqli_query($con,"select password accounts username=".$username);     $result = mysqli_query($con,"select password,username,type,u_name accounts ");     $new = mysql_query($con, "select name,usn,repute,acc_type,u_name pupil ");     $new1= mysql_query($con,"select name,id,repute,acc_type,u_name teacher");               if(mysqli_num_rows($new)>0)         {          while($row = mysqli_fetch_assoc($new)) {                  $pupilaccount = $row['acc_type'];                          if(mysqli_num_rows($new1)>0)                  {                        while($row = mysqli_fetch_assoc($new1)) {                            $teacheraccount = $row['acc_type'];                               if(mysqli_num_rows($result)>0)                              {                                   while($row = mysqli_fetch_assoc($result)) {                                           $pass=$row['password'];                                         $use=$row['username'];                                         $type=$row['type'];                                          if( $type==$teacheraccount , $password == $pass , $username==$use){                                                  header("location:http://localhost/index.php?param=$teacheraccount&param1=$username");                                             exit();                                       }                                       else if($type==$pupilaccount , $password == $pass , $username==$use)                                       {                                             header("location:http://localhost/index.php?param==$pupilaccount&param1=$username");                                                exit();                                          }                                   }                             }                       }         }       }                          }       }     ?> 

error message:

warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in h:\xamp\htdocs\newlogintry.php on line 31

line 31 is:

                          if(mysqli_num_rows($result)>0) 

this error means $result not mysqli_result mysqli_num_rows expects, $result false means corresponding query failed.

$result defined here:

  $result = mysqli_query($con,"select password,username,type,u_name accounts "); 

you need check if query succeeded , if not, error message. recommend reading manual on mysqli @ php.net.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -