-1

I'm trying to insert records into a database table using load data local infile from php script but it's giving me following error:

Invalid query: The used command is not allowed with this MySQL version

However it's working from a mysql command prompt.

shim
  • 8,356
  • 10
  • 70
  • 102
ashish
  • 87
  • 6
  • 4
    Also, what versions of PHP and MySQL? – rws907 Dec 06 '12 at 12:21
  • I think this is due to the permission with which you are connecting to the database. – Sashi Kant Dec 06 '12 at 12:28
  • 2
    I doubt we're talking about permissions. We should get another error message in this case – Alexander Taver Dec 06 '12 at 12:38
  • are you sure you're connecting to the same MySQL database from the command line as you are from within PHP? – SDC Dec 06 '12 at 13:35
  • 1
    Possible duplicate of [LOAD DATA LOCAL INFILE gives the error The used command is not allowed with this MySQL version](https://stackoverflow.com/questions/10737974/load-data-local-infile-gives-the-error-the-used-command-is-not-allowed-with-this) – Stephen Ostermiller Oct 29 '19 at 22:22

1 Answers1

1

Assuming you have correctly enabled local infiles in your my.cnf file in all the appropriate places (mysqld, safe_mysqld, mysql), make sure your MySQL connection parameters in your PHP code sets the 'client_flags' option.

Example:

mysql_connect(HOST,USER,PASS,false,128);

The last parameter of 128 enables local files. See the PHP manual for more info:

Jim T.
  • 79
  • 4