Page 1 of 1

MYSQL Fields with brackets in them?

Posted: Thu Aug 11, 2005 9:25 pm
by Nerdstyle
Hey I was working on a PHP script and I wanted to have some of my mysql fields names be in the form of an array but it won't work with mysql_fetch_object is there a way to do this? Or is there a better way of doing what I am trying to do?

Code: Select all

// the name of my field is "buyamount[0]"

$result = mysql_query("SELECT * FROM u_store WHERE uid = '$uid'") or die('Query failed. ' . mysql_error()); 
$store = mysql_fetch_object( $result );

echo "$store->buyamount[0]";
I don't get anything as output.

Posted: Thu Aug 11, 2005 10:12 pm
by s.dot

Code: Select all

$result = mysql_query("SELECT * FROM u_store WHERE uid = '$uid'") or die('Query failed. ' . mysql_error()); 
$array = mysql_fetch_assoc($result);
$array is an array of associative values for the result. To return the indexes uses mysql_fetch_row(). To return indexes and associative values use mysql_fetch_array().