stevieontario Posted February 21, 2010 Share Posted February 21, 2010 Hi everyone, I have stared at the following problem for so long that I may be missing something very elementary; I was hoping somebody might spot it. I wrote a piece of code which includes a call to a function someone else wrote. They are in two different files: "File.php" (which I wrote) and "Functions1.php." The latter, Functions1.php, contains the fuction the other guy wrote. When I launch File.php to the browser, I get the following message: Warning: get_object_vars() expects parameter 1 to be object, string given in C:\Program Files\xampp\htdocs\dev\Functions1.php on line 20 Here is the pertinent part of File.php: require_once ("Functions1.php"); ////////////////////////////////////////////////////////// $lastxml = basename('c:/program files/xampp/htdocs/dev/xmlfilename.xml'); $output= simplexml_load_file($lastxml); $rr = object2array($output); $fdate = getdatafromfilename($lastxml); $fversion = getdatafromfilename($lastxml,1); $generated_date = trim($rr['IMODocHeader']['CreatedAt']); $generated_date = str_replace("T"," ",$generated_date); /////////// Database Settings ////////////// $db_hostname = "localhost"; $db_name = "db1"; $db_username = "jacksmith"; $db_password = "password1"; $cxn = mysql_connect($db_hostname, $db_username, $db_password); ///////////////////////////////////////////// $insert2sourceinfo2 = "insert into sourceinfo2 (xmlname, filedate, version, generated) VALUES ('$lastxml', '$fdate', '$fversion', '$generated_date')"; mysql_query($insert2sourceinfo2, $cxn); $lastSid = mysql_insert_id(); And here's the code for the function "object2array" in the file Functions1.php: // converts the xml file into a php object; function object2array($object) { $return = NULL; if(is_array($object)) { foreach($object as $key => $value) $return[$key] = object2array($value); } else { $var = get_object_vars($object); if($var) { foreach($var as $key => $value) $return[$key] = object2array($value); } else return strval($object); } return $return; } The variable $lastxml outputs properly when I execute print_r($lastxml), and the variables $fdate and $fversion also output properly. Any ideas? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/ Share on other sites More sharing options...
stevieontario Posted February 21, 2010 Author Share Posted February 21, 2010 I should have also pointed you to line 20 in Functions1.php: $var = get_object_vars($object); Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/#findComment-1015648 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2010 Share Posted February 21, 2010 You already have an existing thread for this problem. Don't start another one. That just looses the history of how you got to this point and what has already been tried, which wastes time for those who already tried to help and those who would. Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/#findComment-1015652 Share on other sites More sharing options...
stevieontario Posted February 21, 2010 Author Share Posted February 21, 2010 sorry, I'm not trying to waste anyone's time. I noticed my earlier thread had gone to page 2 of the previous forum, which gives me to believe it will fall off the radar. Also I felt I had not explained it properly initially; plus I realized I should have posted it to this one in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/#findComment-1015660 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2010 Share Posted February 21, 2010 If you have additional information or clarification to add to a thread, add a post in that thread. You can 'BUMP' existing threads - Users should not "bump" topics that are still on the first page of the forums. If you bump, you must provide additional information. If you resort to bumping, chances are your question needs to be re-thought and re-described Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/#findComment-1015664 Share on other sites More sharing options...
stevieontario Posted February 21, 2010 Author Share Posted February 21, 2010 okay thanks, that was my next question: is there a way to migrate a thread to another forum. Now, another elementary question (and please pardon my inexperience): how exactly do I bump a thread? Quote Link to comment https://forums.phpfreaks.com/topic/192809-function-call-doesnt-work/#findComment-1015683 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.