I've looked everywhere but can't find it, so here goes the bit of php code that just won't work:
$link = mysqli_connect(DB_SERVER, username, password, database);
$link2 = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if(!$link){
echo "error link";
}else{
$query = "SELECT * FROM `user`";
$result = mysqli_query($link, $query);
if(!$result){
echo "error ".mysqli_error($link);
return;
}
while($row = mysqli_fetch_array($result)){
//do things
}
}
The if(!$result) doesn't catch anything, and yet, I keep getting "mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in" errors on the "while" line.
Why?
--EDIT:
A var_dump of $result returns:
object(mysqli_result)#3 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(9)
["lengths"]=>
NULL
["num_rows"]=>
int(588)
["type"]=>
int(0)
}
$mysqli_error($link) is empty
And I also don't think this is a duplicate, I've looked all over StackOverflow and other forums for this and all of them fail to solve my problem, saying that $result must be returning false due to a failure of the query or something, which is clearly not the case, as shown above.