Ok - so I have what should be a simple pull into an array for display in a form - however, I am getting this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in ...Database.php5 on line 30
Basically, the function is built in Database.php5
function fetchRow($result)
{
return mysql_fetch_assoc($result);
}
Then the function is called from another function in utilities.php5 as follows:
function getAllSizes()
{
$data = array();
$result = $GLOBALS['DB']->exec("select * from pricing");
while ($row = $GLOBALS['DB']->fetchRow($result))
$data[$row['picSize']] = $row['picSize'] . ": " . $row['price'];
return $data;
}
And of course that function is called from the page I actually want to display it like so:
$all_sizes = getAllSizes();
Then the page is supposed to display it within a table (for better formatting) like so:
foreach (array_keys ($all_sizes) as $picSize)
{
list($size, $price) = split(":", $picSize);
print '<tr><td>' . $size . '</td>';
print '<td><input type="text" name="' . $size . '" size="15" value="' . $price . '" /></td></tr>';
}
All I am trying to do is pull two columns out of a database and load them into an array - I have given up on a multidimensional array because it wasn't working for me - so I figured I could use the split function... For whatever reason - I can't get past the error with mysql_fetch_assoc... Doesn't make any sense. I have checked and double checked all semi-colons, table and column names for the database, and every quotation mark... If you have an easier solution or can tell me what is wrong with this one - please do - I am open to suggestions...
Thanks
~Rachel~