Witam,
Mam taki kod pliku test.php:
<?php
// 1. Create a database connection
// $connection allows us to keep referring to this connection after it has been established once
// server address, username, password
define("MY_SERVER", "localhost"); define("USERNAME", "użytkownik");
$connection = mysql_connect(localhost
,USERNAME
,PASSWORD
); // you may want to use constants here with a require if (!$connection) {
}
// 2. Select a database to use
$db_select = mysql_select_db(DATABASE
,$connection); // you may want to use a constant here for the db name with a require if (!$db_select) {
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Databases</title>
</head>
<body>
<?php
// 3. Perform database query
// LOAD DATA LOCAL INFILE
// LOAD DATA INFILE
"LOAD XML LOCAL INFILE 'http://testowo.pl/xml/klient.xml'
INTO TABLE my_tabela
('tytul', 'klient_id', 'id_level', 'id_type', 'currency', 'id_country', 'state', 'city', 'short_desc', 'long_desc', 'publish_date', 'expire_date', 'is_active', 'is_featured', 'is_new', 'hits','glng','glat','gzoom', 'address_geocode', 'manage_applicant', 'ext_apply_url');",
$connection);
if (!$result) {
}
?>
</body>
</html>
<?php
// 5. Close connection
?>
oraz klient.xml:
<?xml version="1.0" encoding="UTF-8"?>
<produkty>
<produkt>
<column name="tytul">1</column>
<column name="klient_id">63</column>
<column name="id_level">4</column>
<column name="id_type">2</column>
<column name="currency">EURO</column>
<column name="id_country">71</column>
<column name="state">Champagne-Ardenne</column>
<column name="city">Le Havre</column>
<column name="short_desc">krótki opis</column>
<column name="long_desc">długi opis</column>
<column name="publish_date">2012-03-23 00:00:00</column>
<column name="expire_date">2012-04-22 00:00:00</column>
<column name="is_active">y</column>
<column name="is_featured">0</column>
<column name="is_new">0</column>
<column name="hits">440</column>
<column name="glng">4.0205309000000</column>
<column name="glat">49.2348164</column>
<column name="gzoom">5</column>
<column name="address_geocode">Le Havre, Champagne-Ardenne, Francja</column>
<column name="hotjob_expire">0000-00-00 00:00:00</column>
<column name="manage_applicant">0</column>
<column name="ext_apply_url"></column>
</produkt>
</produkty>
Kiedy wywoluję test.php poprzez przeglądarkę to otrzymuje komunikat blędu:
Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'XML LOCAL INFILE 'http://testowo.pl/xml/klient.xml' INTO TABLE my_tabela ' at line 1
Dodam, że wersja mysqla to 5,1,61. Czy problemem jest wersja mysqla (w podręczniku znalazęłm pierwsze informacje o LoaD XML dopiero w wersji 5,5), czy może problem dotyczy czegoś innego?
pozdrawiam
Ten post edytował guingampe 20.05.2012, 18:21:56