damianraine Posted January 20, 2008 Share Posted January 20, 2008 Hope you can help! I am trying to get some code from XML into MYSQL but I am having a problem, the first variable Product_code is going into the MYSQL database fine however the second variable is going into the database but only showing ARRAY but it should be what is in the XML sheet <?php // set name of XML file $file = "update/three_Mobile.xml"; $host = "localhost"; $user = "root"; $pass = ""; $db = "phones"; $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // load file $xml = simplexml_load_file($file) or die ("Unable to load XML file!"); foreach ($xml->xpath('//product_code') as $Product_Code) { $Long_Name = $xml->product->product_name; $query = "INSERT INTO deals (Dealer,Product_Code,Long_Name) VALUES ('Three','$Product_Code','$Long_Name')"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); } mysql_close($connection); ?> Product_Code is going into the database fine Long_Name is only showing the value "ARRAY" Hope you can help Quote Link to comment https://forums.phpfreaks.com/topic/86925-xml-mysql-php-problem-retreiving-data/ Share on other sites More sharing options...
Barand Posted January 20, 2008 Share Posted January 20, 2008 Then it would appear to be an array of names. Quote Link to comment https://forums.phpfreaks.com/topic/86925-xml-mysql-php-problem-retreiving-data/#findComment-444435 Share on other sites More sharing options...
Fyorl Posted January 20, 2008 Share Posted January 20, 2008 Have a look at <a href="http://php.net/serialize">serialize()</a> Quote Link to comment https://forums.phpfreaks.com/topic/86925-xml-mysql-php-problem-retreiving-data/#findComment-444437 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.