will35010 Posted December 26, 2013 Share Posted December 26, 2013 Hello, I think I've been staring at this too long and now cannot see it straight anymore so another pair of eyes would be greatly appreciated. I have the below code that pulls a result from mysql and puts it into an array. I now need to run a function from my class on one of the items in the array since I am using smarty to template and cannot call the function from the template or shouldn't anyway. <?php ini_set('display_errors', 1); error_reporting(E_ALL); include ('classes/TrackingBoardClass.php'); include ('functions.inc.php'); $clientID = "1"; $TrackingClass = new TrackingBoardClass(); $results = $TrackingClass->GetBoardResults($clientID); if ($results != "") { while ($row2 = mysqli_fetch_assoc($results)) { $boardresults[] = $row2['priorityID']; } } //print_r($boardresults); foreach ($boardresults as $value) { echo $TrackingClass->GetPriority($clientID, $value)."<br>"; } ?> The $TrackingClass->GetPriority is the function that I am trying to run on the results, but I get error: Object of class mysqli_result could not be converted to string. Any help or insights would be greatly appreciated. Thank you! Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 26, 2013 Share Posted December 26, 2013 the only thing that is apparent from the code you posted is that your $TrackingClass->GetPriority() method likely (only you know for sure) returns a mysqli result object and you are trying to echo that. wouldn't you need to to fetch a row from that result set, then access a specific element of that row before you could echo its value? or even better, wouldn't a method named GetPriority() do all the necessary work internally and just return the priority value? Quote Link to comment Share on other sites More sharing options...
Solution will35010 Posted December 26, 2013 Author Solution Share Posted December 26, 2013 the only thing that is apparent from the code you posted is that your $TrackingClass->GetPriority() method likely (only you know for sure) returns a mysqli result object and you are trying to echo that. wouldn't you need to to fetch a row from that result set, then access a specific element of that row before you could echo its value? or even better, wouldn't a method named GetPriority() do all the necessary work internally and just return the priority value? Thank you for pointing me in the right direction. It was the way the function was returning the result. Thank you again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.