ChrisMartino Posted August 2, 2010 Share Posted August 2, 2010 Hey there, Now I was curious if there was a way I could return an array in my function like the following, I currently get a error though: Catchable fatal error: Object of class panel_accounts could not be converted to string in C:\wamp\www\X-HostLTD - Panel\PanelFrontend\index.php on line 21 But can you only return strings?. Here is the function that it errors on: function returnAccountInformation($AccountID) { return mysql_fetch_array(mysql_query("SELECT * FROM ****_***** WHERE *****_***** = '".mysql_escape_string($AccountID)."'")); } Could somebody help me on the matter?, Thank you. P.S sorry for staring out the table names but I don't really want people knowing my database structure hehe. Quote Link to comment https://forums.phpfreaks.com/topic/209542-returning-an-array/ Share on other sites More sharing options...
corbin Posted August 2, 2010 Share Posted August 2, 2010 The problem is that you're trying to convert an object to a string, likely doing so implicitly by trying to echo or print it. Objects that do not have a __toString method do not have any defined mechanism for being converted to a string and as such throw an exception like that one. I need to see more code before I can help you with actual code though. That function you posted does not return an object. Quote Link to comment https://forums.phpfreaks.com/topic/209542-returning-an-array/#findComment-1093974 Share on other sites More sharing options...
Alex Posted August 2, 2010 Share Posted August 2, 2010 This is slightly off topic and won't solve your problem, but you should be using mysql_real_escape_string and not mysql_escape_string which is depreciated. Quote Link to comment https://forums.phpfreaks.com/topic/209542-returning-an-array/#findComment-1093977 Share on other sites More sharing options...
ChrisMartino Posted August 2, 2010 Author Share Posted August 2, 2010 The problem is that you're trying to convert an object to a string, likely doing so implicitly by trying to echo or print it. Objects that do not have a __toString method do not have any defined mechanism for being converted to a string and as such throw an exception like that one. I need to see more code before I can help you with actual code though. That function you posted does not return an object. Thanks for your help, It was a mistype error that caused it, in the functions arguments I put two $'s for the variable, and AlexWD thanks for telling me!, I've just converted them all over now. Quote Link to comment https://forums.phpfreaks.com/topic/209542-returning-an-array/#findComment-1094055 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.