Need Help...Please

Reply

Join Date: Oct 2008
Posts: 1
Reputation: therealme2006 is an unknown quantity at this point 
Solved Threads: 0
therealme2006 therealme2006 is offline Offline
Newbie Poster

Need Help...Please

 
0
  #1
Oct 10th, 2008
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
  1. function fetchRow($result)
  2. {
  3. return mysql_fetch_assoc($result);
  4. }

Then the function is called from another function in utilities.php5 as follows:
  1. function getAllSizes()
  2. {
  3. $data = array();
  4. $result = $GLOBALS['DB']->exec("select * from pricing");
  5. while ($row = $GLOBALS['DB']->fetchRow($result))
  6. $data[$row['picSize']] = $row['picSize'] . ": " . $row['price'];
  7. return $data;
  8. }

And of course that function is called from the page I actually want to display it like so:
  1. $all_sizes = getAllSizes();

Then the page is supposed to display it within a table (for better formatting) like so:
  1. foreach (array_keys ($all_sizes) as $picSize)
  2. {
  3.  
  4. list($size, $price) = split(":", $picSize);
  5. print '<tr><td>' . $size . '</td>';
  6. print '<td><input type="text" name="' . $size . '" size="15" value="' . $price . '" /></td></tr>';
  7. }

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~
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 883
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 144
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Need Help...Please

 
0
  #2
Oct 13th, 2008
Normally it would mean that the connection has not yet been established or an error in your query.

Perhaps the exec() function is returning something different from what you are expecting ?
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum


Views: 515 | Replies: 1
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC