I can't Login to my index.php

Website URL


Error Message

Fatal error : Uncaught Error: Call to a member function fetch_assoc() on bool in /home/vol1000_8/infinityfree.com/if0_34532282/htdocs/EarnMoney/index.php:10 Stack trace: #0 {main} thrown in /home/vol1000_8/infinityfree.com/if0_34532282/htdocs/EarnMoney/index.php on line 10

Other Information

if(isset($_SESSION['islogged']) == "1")
	echo "<script language='javascript'>window.location='users.php';</script>";
	$selectdata123 = $conn->query("select * from `usermaster` where username='".$_POST['username']."' and password='".$_POST['password']."'");
	if($check_row = $selectdata123->fetch_assoc()) {
		echo "<script language='javascript'>window.location='users.php';</script>";
	if($_SESSION['islogged'] !="1")
		<script language="JavaScript" type="text/javascript">	
			alert("Password you entered is wrong, Please try again.");

Your code may be vulnerable the SQL injection. I would fix that before anything else, you may fix this issue while correcting your vulnerable code.


This error tells you that the object on which you’re trying to call the fetch_assoc() function is actually a bool value. Looking at the code, that’s $selectdata123.

Looking at the documentation of the MySQLi query function tells us:

Returns false on failure. For successful queries which produce a result set, such as SELECT, SHOW, DESCRIBE or EXPLAIN , mysqli_query() will return a mysqli_result object. For other successful queries, mysqli_query() will return true .

Given that it’s a SELECT query, it’s likely that the query failed and the result is false. You could be able to get the error message through the $conn->error variable if this happens.

Reading the rest of the documentation of the query function is also a good idea. It has a big red warning banner about SQL injection, which your code is wide open to.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.