You are here: Re: LOAD DATA INFILE via cron « All PHP « IT news, forums, messages
Re: LOAD DATA INFILE via cron

Posted by elyob on 09/28/80 11:19

"elyob" <newsprofile@gmail.com> wrote in message
news:42b933d5$1@news1.homechoice.co.uk...
>
> "NC" <nc@iname.com> wrote in message
> news:1119372214.922756.152180@g44g2000cwa.googlegroups.com...
>> elyob wrote:
>>>
>>> I'm trying to run a LOAD DATA INFILE command which is held in a php file
>>> to be run by cron. (I understand you cannot run sql commands direct from
>>> cron).
>>
>> Of course you can. You can create a shell script like this:
>>
>> mysql -u root -ppassword < file.sql
>>
>> This will execute SQL statements from file.sql.
>
> Oh, okay. Seems googling has it's problems! Must ask more questions on
> groups like these!
>
>>
>>> The command is
>>>
>>> mysql_query("LOAD DATA LOCAL INFILE '/path/to/file.txt' REPLACE INTO
>>> TABLE
>>> 'tablename' FIELDS TERMINATED BY '|' ENCLOSED BY '\"' ESCAPED BY '\\'
>>> LINES
>>> TERMINATED BY '\n'") or die("LOAD Failed ".mysql_error());
>>>
>>> I get an error "You have an error in your SQL syntax.", but I can run
>>> the
>>> exact same SQL statement via SSH into MySQL command line.
>>
>> This is not true. Right now, you have the name of the table
>> enclosed in single quotes ('tablename'), which is a syntax error.
>> You should ether delete the single quotes or replace them with
>> backticks (`tablename`).
>>
>
> Strange, because I have been ssh'ing into my server and mysql. They run
> fine with the table name in single quotes. That was when I was happy that
> the commands were working fine and the results were as expected.
>

The other oddity is that I copied the original command from phpMyAdmin and
just edited it accordingly.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация