Current location: Hot Scripts Forums » Programming Languages » PHP » pb with load data local infile


pb with load data local infile

Reply
  #1 (permalink)  
Old 05-26-05, 07:37 PM
electronico electronico is offline
New Member
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question pb with load data local infile

Hi all,

First excuse me if this thread sounds newbie, but i'm not a php-sql guru at all ...

server :
linux / redhat with kernel : 2.4.21-4.0.1.EL
Apache version 1.3.31 (Unix)
PHP version 4.3.9
MySQL version 4.0.18-standard
cPanel Build 9.9.9-STABLE 15
Theme cPanel X v2.5.0

Aim :
scan a directory, create a txt file with its content and insert it into mysql

The problem is with the txt file insertion into mysql.
For this I was using the LOAD DATA LOCAL INFILE like this :
Code:
$result = mysql_db_query($sql_db,"LOAD DATA LOCAL INFILE 'dbexport.txt' INTO TABLE $sql_tbl FIELDS TERMINATED BY ',' ENCLOSED BY '\"'") or die ("Requete DATA LOAD invalide ".mysql_errno() ." : ".mysql_error() ."");
and it was running fine.

Since mysql version has been updated to 4.0.18, I get a 1148 error : The used command is not allowed with this MySQL version

I have seeked the web for a long time and found that this function is disabled in new mysql versions for security reason.

As I can't re-compile mysql, I read that :
Code:
mysql_options(... MYSQL_OPT_LOCAL_INFILE, 0)
could be used, but I haven't been able to use it ...
Could you please assist this this ?

Now I have to download the txt file from the server and insert it from phpmyadmin , that's a real pain as previously a simple browsing was doing the job.

I was wondering if there are turnaround for this ?
And why can phpmyadmin insert this txt file upload to a /tmp/ directory and not me from a .php file ?

Thanks in advance for your time and understanding (excuse my english in case it hurts).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-26-05, 07:57 PM
Jaffizzle Jaffizzle is offline
Newbie Coder
 
Join Date: May 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
if you are looking for a mysql_db_query replacement

i believe you can use a combination of

mysql_select_db and mysql_query


Your SQL is too crazy for me..hehe im not at that level ,
so Im not 100% sure what you are trying to do. It looks like you are trying to import the .txt file via script, if so I never done that before
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-26-05, 09:01 PM
electronico electronico is offline
New Member
 
Join Date: May 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for your answer.
Yes, I want to import the txt file via script and it was working with the old mysql version.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-26-05, 11:49 PM
Jaffizzle Jaffizzle is offline
Newbie Coder
 
Join Date: May 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

mysql_select_db($sql_db); 


$result=mysql_query("LOAD DATA LOCAL INFILE 'dbexport.txt' INTO TABLE $sql_tbl FIELDS TERMINATED BY ',' ENCLOSED BY '\"'") or die ("Requete DATA LOAD invalide ".mysql_errno() ." : ".mysql_error() .""); 
That should be the equivalent of mysql_db_query if you didnt get it yet.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to load Excel data in VB-textbox or label? Nellie Visual Basic 1 03-15-05 07:44 PM
Temporary Data Storage eddyvlad PHP 2 02-21-05 10:36 AM
Script for uploading data from local database to production database pual_cruzs PHP 1 07-06-04 01:44 AM
load data in combo box AlexGM14 PHP 1 12-29-03 09:15 PM


All times are GMT -5. The time now is 06:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.