bravo14 Posted December 6, 2014 Share Posted December 6, 2014 Hi all i am using the code below, but am getting the error Object of class mysqli_result could not be converted to int <?php $sql="SELECT lng,lng_prefix FROM tbl_languages where active = 1"; $result=mysqli_query($dbConn, $sql)or die(mysqli_error($dbConn)); //problem line if(mysqli_num_rows($result==1)){ ?> The code continues with what I want to happen based on the result. What does the error mean and how do I fix it? Link to comment https://forums.phpfreaks.com/topic/292934-object-of-class-mysqli_result-could-not-be-converted-to-int/ Share on other sites More sharing options...
maxxd Posted December 6, 2014 Share Posted December 6, 2014 You've got your end parenthesis in the wrong spot. change if(mysqli_num_rows($result==1)){ to if(mysqli_num_rows($result)==1){ and it should work. Link to comment https://forums.phpfreaks.com/topic/292934-object-of-class-mysqli_result-could-not-be-converted-to-int/#findComment-1498784 Share on other sites More sharing options...
kicken Posted December 6, 2014 Share Posted December 6, 2014 Your closing parenthesis for the function call is in the wrong spot. You're trying to call mysqli_num_rows on the result of the $result==1 comparison. Link to comment https://forums.phpfreaks.com/topic/292934-object-of-class-mysqli_result-could-not-be-converted-to-int/#findComment-1498785 Share on other sites More sharing options...
hansford Posted December 6, 2014 Share Posted December 6, 2014 Without correct parenthesis, you're code is being in interpreted as trying to cast the result set to an integer. Link to comment https://forums.phpfreaks.com/topic/292934-object-of-class-mysqli_result-could-not-be-converted-to-int/#findComment-1498787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.