PHP codes shows a warning while connecting to MySQL [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers



  • Reference - What does this error mean in PHP?

    32 answers




i have written a piece of code in order to give access to my android app to connect to the MySQL database through PHP.
It works fine but log shows a warning says:




Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsapp_login.php on line 7




this is my php for connecting the database (app_conn.php):



<?php
$db_name="score_test";
$mysql_username="root";
$mysql_password="PxyG8PPJFRGxAmhP";
$server_name="localhost";
$conn= mysqli_connect($server_name,$mysql_username,$mysql_password,$db_name);
if(mysqli_connect_errno()== false){
echo "Done";
}
?>


and the login php (app_login.php):



<?php
require "app_conn.php";
$user_name = "test";
$user_pass="481";
$mysql_qry= "select * from score_test where C_USER like '$user_name' and C_SCORE like '$user_pass';";
$result = mysqli_query($conn , $mysql_qry);
if(mysqli_num_rows($result) == 0){
echo "Login Succesful";
}
else{
echo "Login Failed";
}
?>









share|improve this question















marked as duplicate by FrankerZ, Masivuye Cokile, Jeto, Nick, RiggsFolly mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 12:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Your script is at risk for SQL Injection Attacks.

    – FrankerZ
    Nov 23 '18 at 12:16






  • 1





    @TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

    – Magnus Eriksson
    Nov 23 '18 at 12:24


















0
















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers



  • Reference - What does this error mean in PHP?

    32 answers




i have written a piece of code in order to give access to my android app to connect to the MySQL database through PHP.
It works fine but log shows a warning says:




Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsapp_login.php on line 7




this is my php for connecting the database (app_conn.php):



<?php
$db_name="score_test";
$mysql_username="root";
$mysql_password="PxyG8PPJFRGxAmhP";
$server_name="localhost";
$conn= mysqli_connect($server_name,$mysql_username,$mysql_password,$db_name);
if(mysqli_connect_errno()== false){
echo "Done";
}
?>


and the login php (app_login.php):



<?php
require "app_conn.php";
$user_name = "test";
$user_pass="481";
$mysql_qry= "select * from score_test where C_USER like '$user_name' and C_SCORE like '$user_pass';";
$result = mysqli_query($conn , $mysql_qry);
if(mysqli_num_rows($result) == 0){
echo "Login Succesful";
}
else{
echo "Login Failed";
}
?>









share|improve this question















marked as duplicate by FrankerZ, Masivuye Cokile, Jeto, Nick, RiggsFolly mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 12:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 2





    Your script is at risk for SQL Injection Attacks.

    – FrankerZ
    Nov 23 '18 at 12:16






  • 1





    @TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

    – Magnus Eriksson
    Nov 23 '18 at 12:24














0












0








0









This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers



  • Reference - What does this error mean in PHP?

    32 answers




i have written a piece of code in order to give access to my android app to connect to the MySQL database through PHP.
It works fine but log shows a warning says:




Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsapp_login.php on line 7




this is my php for connecting the database (app_conn.php):



<?php
$db_name="score_test";
$mysql_username="root";
$mysql_password="PxyG8PPJFRGxAmhP";
$server_name="localhost";
$conn= mysqli_connect($server_name,$mysql_username,$mysql_password,$db_name);
if(mysqli_connect_errno()== false){
echo "Done";
}
?>


and the login php (app_login.php):



<?php
require "app_conn.php";
$user_name = "test";
$user_pass="481";
$mysql_qry= "select * from score_test where C_USER like '$user_name' and C_SCORE like '$user_pass';";
$result = mysqli_query($conn , $mysql_qry);
if(mysqli_num_rows($result) == 0){
echo "Login Succesful";
}
else{
echo "Login Failed";
}
?>









share|improve this question

















This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers



  • Reference - What does this error mean in PHP?

    32 answers




i have written a piece of code in order to give access to my android app to connect to the MySQL database through PHP.
It works fine but log shows a warning says:




Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:xampphtdocsapp_login.php on line 7




this is my php for connecting the database (app_conn.php):



<?php
$db_name="score_test";
$mysql_username="root";
$mysql_password="PxyG8PPJFRGxAmhP";
$server_name="localhost";
$conn= mysqli_connect($server_name,$mysql_username,$mysql_password,$db_name);
if(mysqli_connect_errno()== false){
echo "Done";
}
?>


and the login php (app_login.php):



<?php
require "app_conn.php";
$user_name = "test";
$user_pass="481";
$mysql_qry= "select * from score_test where C_USER like '$user_name' and C_SCORE like '$user_pass';";
$result = mysqli_query($conn , $mysql_qry);
if(mysqli_num_rows($result) == 0){
echo "Login Succesful";
}
else{
echo "Login Failed";
}
?>




This question already has an answer here:




  • mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result

    32 answers



  • Reference - What does this error mean in PHP?

    32 answers








php mysql mysqli






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 12:17









Masivuye Cokile

4,39421431




4,39421431










asked Nov 23 '18 at 12:15









RegetixRegetix

12




12




marked as duplicate by FrankerZ, Masivuye Cokile, Jeto, Nick, RiggsFolly mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 12:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by FrankerZ, Masivuye Cokile, Jeto, Nick, RiggsFolly mysql
Users with the  mysql badge can single-handedly close mysql questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 23 '18 at 12:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    Your script is at risk for SQL Injection Attacks.

    – FrankerZ
    Nov 23 '18 at 12:16






  • 1





    @TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

    – Magnus Eriksson
    Nov 23 '18 at 12:24














  • 2





    Your script is at risk for SQL Injection Attacks.

    – FrankerZ
    Nov 23 '18 at 12:16






  • 1





    @TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

    – Magnus Eriksson
    Nov 23 '18 at 12:24








2




2





Your script is at risk for SQL Injection Attacks.

– FrankerZ
Nov 23 '18 at 12:16





Your script is at risk for SQL Injection Attacks.

– FrankerZ
Nov 23 '18 at 12:16




1




1





@TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

– Magnus Eriksson
Nov 23 '18 at 12:24





@TobiasF. - The OP is only using mysqli_. It's only a few of their variables that's called $mysql_* which doesn't matter.

– Magnus Eriksson
Nov 23 '18 at 12:24












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out