Jump to content

XML - MYSQL - PHP Problem Retreiving Data


damianraine

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/86925-xml-mysql-php-problem-retreiving-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.