bezzoon
bezzoon

Reputation: 2019

Getting an odd result: mysqli_fetch_array() expects parameter 1 to be mysqli_result

I keep getting weird results from this query.

Not that I am not using PDA because this is just a prototype. In production I plan on tightening all of the screws and making it more secure.

include ('../includes/DBConnect.php'); //exactly how it is in other working files
$query = "SELECT * FROM CHARACTERS WHERE USER_ID=(SELECT ID FROM USERS WHERE EMAIL='"+$_SESSION['user']+"') ORDER BY id DESC"; //I have copy pasted this into mysql and it worked, switching the session variable with a string

I get an error with the this line

while($row = mysqli_fetch_array($character_list)){

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\Node2\public\main.php on line 36

I know this has to be stupid. I can't figure it out. I just looked at documentation and other files I have written that worked. And a few stack overflow threads to no avail.

Thank you so much.

Upvotes: 0

Views: 49

Answers (1)

gen_Eric
gen_Eric

Reputation: 227180

You're using + instead of . to concatenate strings. Gotta remember this is PHP, not JavaScript ;)

$query = "SELECT * FROM CHARACTERS WHERE USER_ID=(SELECT ID FROM USERS WHERE EMAIL='".$_SESSION['user']."') ORDER BY id DESC";

Upvotes: 2

Related Questions