To explain the context I have a CSV file through which I'm looping.
I already checked with the following code , I'm actually ready each and every line of my CSV file.
if (file_exists($file)){
$fic = fopen($file, 'rb');
$linecount = 0;
for ($ligne = fgetcsv($fic, 1024,";"); !feof($fic); $ligne = fgetcsv($fic, 1024,";")) {
$linecount++;
}
}
else {
/*do smth*/
}
echo $linecount;
But when I replace $linecount++ with what I realy want my code to do :
$codeArticle = $ligne[0]; //Code Article
$nomArticle = $ligne[1]; //Nom Article
$refGamme = $ligne[2]; //Référence Gamme
$nomGamme = $ligne[3]; //Nom Gamme
$codeSSRef = $ligne[4]; //Code Sous Référence
$libelleSSRef = $ligne[5]; //Libellé Sous Référence
$queryGammes = "INSERT INTO Gamme VALUES('$refGamme','$nomGamme');";
$querySSRef = "INSERT INTO SS_Ref VALUES('$codeSSRef','$libelleSSRef');";
$queryProduits = "INSERT INTO Produit VALUES('$codeArticle','$nomArticle',NULL,'$refGamme','$codeSSRef');";
$result = $pdo->query($queryGammes);
$result = $pdo->query($querySSRef);
$result = $pdo->query($queryProduits);
I got no error with this code running but when I look into my db (mysql) I only have 339 total rows in the table named Produit where i should have 1 line per CSV line. Theese rows are actualy great , the requests runned great but I can't figure out why this code doesn't insert every line of my file into my DB.
Any advice please ? I'm realy stuck here and it's important so I'll take any piece of advice.