-1

I made a database on MySQL but when I am trying to login through PHP file I get 2 warnings:

Warning: mysql_query() expects parameter 1 to be string, object given in C:\Xampp\htdocs\login.php on line 7

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\Xampp\htdocs\login.php on line 8
faileddddd

Connection.php

<?php

$mysql_usernmae="root";
$mysql_password="123";
$db="map";

$db= new mysqli('localhost',$mysql_usernmae,$mysql_password,$db);
echo "Connection successfull";
?>

Login.php

<?php
require "connection.php";
$user_name="123";
$user_pass="123";
$mysql_qry="select * from user_info where user_name like
 ' $user_name' and user_password like '$user_pass';";
$result=mysql_query($db,$mysql_qry);
if (mysqli_num_rows($result)>0)
{
 echo "login Successsss";
}
else
{
 echo "faileddddd";
}
?>
Community
  • 1
  • 1
Freaks
  • 11
  • 1
  • 2
    **WARNING**: Writing your own access control layer is not easy and there are many opportunities to get it severely wrong. Please, do not write your own authentication system when any modern [development framework](http://codegeekz.com/best-php-frameworks-for-developers/) like [Laravel](http://laravel.com/) comes with a robust [authentication system](https://laravel.com/docs/5.2/authentication) built-in. At the absolute least follow [recommended security best practices](http://www.phptherightway.com/#security) and **never store passwords as plain-text**. – tadman Sep 29 '16 at 15:16
  • 2
    **WARNING**: You're mixing [`mysql_query`](http://php.net/manual/en/function.mysql-query.php) and `mysqli`, something that you absolutely should not do. Use *only* `mysqli` functions. To avoid confusion, use the object-oriented interface to make mistakes really obvious rather than a single letter different. – tadman Sep 29 '16 at 15:17

1 Answers1

0

Yesss! Okay the mistake was just in login.php file write,

$result=mysqli_query($db,$mysql_qry);

instead of

$result=mysql_query($db,$mysql_qry);
Jees K Denny
  • 531
  • 5
  • 27
Freaks
  • 11
  • 1