I want to LOAD INFILES for all files in the link directory.
I also need the 3 digits before the file type extension input into a var and
another SQL to UPDATE the location_code.
The names of the files are lik:
$file="somejibberish123.txt";
The 123 is the location code
$dir = 'link/'
I am getting the warning:
Warning: readdir(): supplied argument is not a valid Directory resource
The directory is on a server.
I can create folders and files but not delete them.
It is read only. I don't see what is invalid about the resource?
Here is the script:
the include("db.php");
is the connection to mysql and the link
include("db.php");
$dir = 'link/';
while($file = readdir($dir)) {
array_push($files,"$file");
echo $file; }
closedir($dir);
foreach ($files as $val){
$location_code = strpos($files, -6, 3);
$sql = "LOAD DATA INFILE $files INTO TABLE `cart_order`.inventory_tmp ";
$sql.= "IGNORE 1 LINES ";
$result=mysql_query($sql);
$sql = "UPDATE TABLE `cart_order`.inventory_tmp";
$sql.= "SET cart_order.location_code ";
$result=mysql_query($sql);
}
Do I need a 2nd loop? Thanks,