Welcome to WebmasterWorld Guest from 3.85.245.126

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Challenge: LOAD DATA LOCAL INFILE command used from a PHP script

Problem: The used command is not allowed with this MySQL version

     
10:51 am on Oct 28, 2005 (gmt 0)

New User

10+ Year Member

joined:Feb 24, 2005
posts:20
votes: 0


Hi!

I have a problem with my web host,
they have a limit on 36000 inserts to my mysql database.

User 'user' has exceeded the 'max_updates' resource (current value: 36000)

This happen when importing a cvs file with 61000 lines.

Then I realized that using phpmyadmin works just fine, using the feature:
Insert data from a text file into the table

phpmyadmin use this command:
LOAD DATA LOCAL INFILE '/tmp/phpTAhBie' INTO TABLE `iptoc` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'

And here is the strange part, it works perfectly from phpmyadmin, but when doing it myself in a separate php script, then I get this message:
The used command is not allowed with this MySQL version

Here is a part of my code:
$sql = "LOAD DATA LOCAL INFILE '/tmp/phpmyskwi' INTO TABLE `iptoco` FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\r\\n'";

$result = mysql_query($sql, $dblink) or die("load -" . mysql_error());

I've been looking into the phpmyadmin code, and I cannot seem to figure out what they do differently!

Anyone with some insight here that can help me out, or give some tips?

I would like to make a cron job out of this.

11:41 am on Oct 28, 2005 (gmt 0)

New User

10+ Year Member

joined:Feb 24, 2005
posts:20
votes: 0


Problem solved!

Added this, with inspiration from phpmyadmin:

$client_flags ¦= 128;

$dblink = mysql_connect($dbhost, $dbuser, $dbpass, FALSE, $client_flags);
mysql_select_db($dbname, $dblink);

And then it works!