It is not possible to load data from a downloaded (local) file since mysql was updated (current version: server version: 5.5.44-0 + deb8u1 (Debian)), implied files:
dbconnection.php
<?php $server = "localhost"; $user = "TheUser"; $pass = "ThePass"; $db_name = "DbName"; $link = mysql_connect($server, $user, $pass); mysql_select_db($db_name); mysql_set_charset('utf8', $link); ?>
send2db.php
<?php include 'dbconnection.php'; mysql_select_db("DbName") or die(mysql_error()); $query = "LOAD DATA LOCAL INFILE '$file' INTO TABLE `T1` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"' "; mysql_query($query) or die(mysql_error()); ?>
The error says:
ERROR 1148 (42000): The used command is not allowed with this MySQL version
Inside mysql:
SHOW GLOBAL VARIABLES LIKE 'local_infile'; +
But if I access mysql this way, the files can be downloaded:
mysql --local-infile -p
So my question is: can I set this parameter in the dbconnection.php file, I have tried many ways many times, but I do not have time, I read the messages about my.cnf configuration and some other materials, but nothing works, any suggestion ?
thanks
UPDATE: I was absent, changing the code of the entire network to mysqli, ufff !!, well following the recommendations from the answers below. I made the following code, but did not succeed, I still get the message: "The command used is not allowed using this version of MySQL." The implied files are as follows:
acessdb.php
<?php $link = new mysqli($server, $user, $pass, $dbname); ?>
send2db.php
<?php include 'acessdb.php'; $link->options(MYSQLI_OPT_LOCAL_INFILE, true); mysqli_query($link, "LOAD DATA LOCAL INFILE 'upfiles/file.csv' INTO TABLE `T1` FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'") or die(mysqli_error($link)); $link->options(MYSQLI_OPT_LOCAL_INFILE, false); ?>
Any suggestions?