Witam,

Mam taki kod pliku test.php:
  1. <?php
  2. // 1. Create a database connection
  3. // $connection allows us to keep referring to this connection after it has been established once
  4. // server address, username, password
  5. define("MY_SERVER", "localhost");
  6. define("USERNAME", "użytkownik");
  7. define("PASSWORD", "hasło");
  8. define("DATABASE", "baza");
  9.  
  10. $connection = mysql_connect(localhost,USERNAME,PASSWORD); // you may want to use constants here with a require
  11. if (!$connection) {
  12. die("Database connection failed: " . mysql_error());
  13. }
  14.  
  15. // 2. Select a database to use
  16. $db_select = mysql_select_db(DATABASE,$connection); // you may want to use a constant here for the db name with a require
  17. if (!$db_select) {
  18. die("Database selection failed: " . mysql_error());
  19. }
  20. ?>
  21.  
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head>
  25.  
  26. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  27. <title>Databases</title>
  28.  
  29. </head>
  30.  
  31. <body>
  32.  
  33. <?php
  34. // 3. Perform database query
  35.  
  36. // LOAD DATA LOCAL INFILE
  37. // LOAD DATA INFILE
  38.  
  39. $result = mysql_query (
  40. "LOAD XML LOCAL INFILE 'http://testowo.pl/xml/klient.xml'
  41. INTO TABLE my_tabela
  42. ('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');",
  43. $connection);
  44. if (!$result) {
  45. die("Database query failed: " . mysql_error());
  46. }
  47.  
  48.  
  49. ?>
  50. </body>
  51. </html>
  52.  
  53. <?php
  54. // 5. Close connection
  55. mysql_close($connection);
  56. ?>


oraz klient.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <produkty>
  3. <produkt>
  4. <column name="tytul">1</column>
  5. <column name="klient_id">63</column>
  6. <column name="id_level">4</column>
  7. <column name="id_type">2</column>
  8. <column name="currency">EURO</column>
  9. <column name="id_country">71</column>
  10. <column name="state">Champagne-Ardenne</column>
  11. <column name="city">Le Havre</column>
  12. <column name="short_desc">krótki opis</column>
  13. <column name="long_desc">długi opis</column>
  14. <column name="publish_date">2012-03-23 00:00:00</column>
  15. <column name="expire_date">2012-04-22 00:00:00</column>
  16. <column name="is_active">y</column>
  17. <column name="is_featured">0</column>
  18. <column name="is_new">0</column>
  19. <column name="hits">440</column>
  20. <column name="glng">4.0205309000000</column>
  21. <column name="glat">49.2348164</column>
  22. <column name="gzoom">5</column>
  23. <column name="address_geocode">Le Havre, Champagne-Ardenne, Francja</column>
  24. <column name="hotjob_expire">0000-00-00 00:00:00</column>
  25. <column name="manage_applicant">0</column>
  26. <column name="ext_apply_url"></column>
  27. </produkt>
  28. </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