mysqli_fetch_array confusing results

I'm an experienced ASP/MSSQL programmer trying to make the move to PHP/MYSQL and I've been able to wrangle my way up to now. I have a simple SQL query that works great in mymcadmin but gets lost in PHP. I've simplified it a bit here but this is the actual code. Any help would be appreciated!

I believe, since you did mysqli_fetch_array() you are getting a 0 index result. If you want to use the column name, use mysqli_fetch_assoc() instead, or change this line:

$xml+='<zip>' . $row['zip'] . '</zip>';

to

$xml+='<zip>' . $row[0] . '</zip>';

and that should work.

diafol

4 Years Ago

Neither of the above are correct as mysqli_fetch_array() gives both types of array (indexed and associative) as default. Since you did not specify a resulttype, both will be returned. However, if you do not need an indexed array, you can use either the mysqli_fetch_assoc() mentioned by ryantroop (NOT mysql_fetch_assoc!!), or you can use: