Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.