0
good morning. I am uploading csv with php, the same does the processing but gives the following error: "Undefined offset:" I cannot identify this error and treat... Help me!..
0
good morning. I am uploading csv with php, the same does the processing but gives the following error: "Undefined offset:" I cannot identify this error and treat... Help me!..
0
The error of "Undefined offset" usually happens when you are trying to do some operation with the nonexistent value of an array.
In CSV (or excel) files sometimes comes empty rows and columns, which it understands as being part to file (even if it has no value at all). So before you perform explodes, or other operations, it is always good to test whether the array value actually exists:
if (isset($_FILES['file']['name']) && !empty($_FILES['file']['name'])) { [...] }
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Put your code so we can help
– Costamilam
Follows the Code:
– Expert Ortega
First Part: $arrFileName = explode('. ', $_FILES['file]['name']); if ($arrFileName[0] = 'csv') { $Handle = fopen($_FILES['file']['tmp_name'], "r"); fgetcsv($Handle);
– Expert Ortega
second part: while (($data = fgetcsv($Handle, 1000, ";")) !== FALSE) { $WORKORDERUID = mysqli_real_escape_string($Conn, $data[0]);
– Expert Ortega
the variable $date[0] goes up to the variable $date[19]
– Expert Ortega
hence comes the import query, Select into....
– Expert Ortega
You can edit your question and add code there, it is also good format it, thus becomes more readable. After making can delete the comments :)
– Costamilam