c_shelswell Posted March 27, 2009 Share Posted March 27, 2009 Hi I'm still struggling to put together this database class that I found but am trying to learn how it works exactly. I'm basically grabbing some data from the db this all works great and i'm returned the array: Array ( [0] => stdClass Object ( [username] => cshelswell ) ) the class then sends that back to a function but that's when i'm getting: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\a1\require\database_class.php on line 112 The function it's sending back to is: <?php public function selectFromDB($data) { /** have cut the above out the sql is good tho **/ $this->result = $this->query($sql); /** it's this bit it's getting stuck at **/ if($this->result) { $rows = $this->fetchRows(); } return $rows; } private function fetchRows() { $rows = array(); if($this->result) { while($row = mysql_fetch_object($this->result)) { $rows[] = $row; } } return $rows; } private function query($sql) { $this->result = mysql_query($sql) or die (mysql_error()); return $this->fetchRows(); } ?> I'm not to familiar with mysql_fetch_object i have looked it up and i think i get it but the class i have does as above so assume it did work for him. I guess i just need to separate the array so i only return: [username] => cshelswell Any help would be great cheers Link to comment https://forums.phpfreaks.com/topic/151404-bit-stuck-with-this-database-class-returning-arrays/ Share on other sites More sharing options...
c_shelswell Posted March 27, 2009 Author Share Posted March 27, 2009 Just bumping this anyone got any ideas? Cheers Link to comment https://forums.phpfreaks.com/topic/151404-bit-stuck-with-this-database-class-returning-arrays/#findComment-795524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.