Cant figure this out to save my life

this is my code below I can not figure out why its giving me this error:

“Parse error: syntax error, unexpected ‘while’ (T_WHILE) in D:\xampp\htdocs\test.php on line 8”

this is just a test page I have so I can test errors by themselves.



<?php 
	require('db/db.inc.php');
	
	$sql = "SELECT * FROM owned WHERE user_id = 1";
	$result = $conn->query($sql);
	
	if ($result->num_rows > 0) {
    	   while($row = $result->fetch_assoc()) {
        
    	   }
	} else {
    	   echo "0 results";
	}
	$conn->close();
?>


Do you want to compare or do you want to assign a value here?

I want to show everything from the database that is under that ‘users id’ in the table “owned”

I wanted to say that the while loop expects a bool value. But what you did was an assignment to the variable $row:
$row = $result->fetch_assoc()

Shouldn’t it be something like this instead?

$row == $result->fetch_assoc()

nah I try that to as a last resort and that didn’t change it all that error is saying is that while is suppose to be there but in reality it is and I cant figure out why its saying that

Have you checked that you didn’t zoom in (reset zoom by pressing CTRL + 0)? Tried different browser?

I have multiple browser on the pc and there all doing the same thing this is just really frustrating because I know I did it right but its saying its wrong

Save the php file in UTF-8 format .

update the database column in UTF-8 format and check

Are round brackets missing for num_rows, i.e. num_rows()?

Are you sure while is the correct construct and not a foreach loop?