SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Automate Data Import

  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automate Data Import

    I'm trying to automate transfering data from a non-SQL database to MySQL. The text file containing the data has the following format:

    TRUNCATE TABLE 'products';
    INSERT INTO 'products' VALUES (1,2,'Some Product',9.95);

    Using phpMyAdmin 2.6.0, the "Choose File" works nicely every time to import 7600 data records into MySQL 3.23.56.

    But file_get_contents() in a PHP script produces "SQL systax errors" with the same text file.

    Can someone suggest a PHP / SQL approach that will import cleanly?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check to see if this setting is turned on by using phpinfo();

    magic_quotes_runtime


    also, echo the result of file_get_contents to see if you notice anything.

    btw- how big is the file?

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have turned on magic_quotes_runtime but it did not make any difference. When the error occurs, it complains about SQL syntax around the semi-colon on the first line and then displays the entire file inside my browser window.

    This file is 750 K and will eventually be 2,000 K when I add the other 5 tables.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •