I’m not too sure what’s going on here but I’m trying to echo a value from mysql and when I do, it just shows double for some reason
Code:
$result = MySqlQuery('SELECT value FROM table WHERE id=1');
$value = mysqli_fetch_assoc($result);
echo implode($value);
It displays 7373, the value is 73 in the DB.
I also tried echoing * instead of value, it also displays the entire row double.
Removing the echo there just displays nothing anymore so it’s not like it’s being echoed through another function either so I’m confused
Also the MySqlQuery() function is used by pretty much everything else on the site where it doesn’t display double results as well
mysqli_fetch_arrayreturns an array with twice as many elements as the columns you select by default (each column is represented twice). I assume that themysqli_fetch_associn your code is a typo.To solve the problem, either use
mysqli_fetch_associnstead or pass one ofMYSQLI_ASSOCandMYSQLI_NUMas the second parameter tomysqli_fetch_array. As a rule of thumb, usemysqli_fetch_assocunless you know you need something else.