Is there a setting in the php.ini file that would cause this to happen:
Using data from mysql_fetch_array($query, MYSQL_ASSOC)
$data[name] fails
but
$data['name'] is okay. (It's the single quotes that work.)
Or perhaps it's something new in a more current release of php I am unaware of because I've been using the first method for quite sometime.
Any ideas?
Thanks!
Well ofcause... The name needs to be a string, therfore you need to type $data['name'] or date["name"]... One other thing you could do is this:
<?php
$field = "name";
echo $data[$field];
?>Alxandr
Alxandr is right - in php 4, 5, & 6 you must put strings and chars inside a '' (single quote) if you want that value stored, or in a "" (double quote) if you want that value processed and then stored.
<?php
$field = "name";
$data = "We are making a string with a $field";
//Contents of $data: "We are making a string with a name";
$data2 = 'We are making a string with a $field';
//Contents of $data2: "We are making a string with a $field";
?>