Комментарии:
It was a great video. I learned a lot.
Ответитьwhere's the code for the button choose file?
ОтветитьMuitissimo obrigado. Era exatamente isto que eu estava procurando. Valeu irmão.
Ответитьi got an error as Undefined index: file
Ответитьhow about the csv file size is 60 mb and has 60k rows? Which code should be changed?
Ответитьis there anyway that column automatically adjust to the csv file in the database while uploading
Ответитьif(isset($_POST["import"])){
$filename = $_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"]>0){
$file = fopen($filename,"r");
while (($column) = fgetcsv ($file, 10000, ",")) !== FALSE) {
$sqlinsert = "insert into data (name,type) values ('".$column[0]."','".$column[1]."')";
$result = mysqli_query($conn,$sqlinsert);
if (!empty($result)) {
echo "csv imported";
}else{
echo "problem";
}
}
}
} ------- line 12 errr ??--
AWESOME! IT WORKED! THANK YOU SO MUCH!
Ответитьcan u drop the csv file structure?
Ответитьproblem: Undefined array key "file"
Warning: Trying to access array offset on value of type null line 6
This is my code, i dont even get an error, nothing happens please help, my csv file was created with notepadd ++ and have 3 columns of string
<?php
$conn=mysqli_connect("localhost","root","","csv");
if(isset($_POST["import"])){
$fileName=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"]>0){
$file = fopen($filename,"r");
while(($column=fgetcsv($file,1000,","))!==FALSE)
{
$sqlInsert="Insert into data(name,type,email) values('".$column[0]."', '".$column[1]."', '".$column[2]."')";
$result=mysqli_query($conn,$sqlInsert);
if(!empty($result)){
echo "CSV data imported into database";
}
else{
echo "Problem in importing csv";
}
}
}
}
?>
<form class="form-horizoontal" action="" method="post" name="uploadCsv" enctype="multipart/form-data">
<div>
<label>Chose a csv file</label>
<input type="file" name="file" accept=".csv">
<button type="submit" name="Submit">Import</button>
</div>
</form>
Muy fácil, espero me salga igual.
Ответитьwhich code editor are you using? I've been using notepad++ which seems to lack some features.
ОтветитьProblem : Only 0th row i'm getting in array but other rows are missing...
ОтветитьI try to copy all codes but didn't work on my scratch, always echoing "Problem in importing csv"
ОтветитьCan i get the code please
ОтветитьSir....I have got error
This while loop is not getting terminated
Hi CodeFlix - I've got this error "Warning: Undefined array key "temp_name". May I know where is this "temp_name"
Ответитьdoes your CSV file contains the table column names?
Ответитьcan I get this code?
Ответитьi hope you react soon bro
Ответить2.51 what did you do there on line 13? with that comma
because i have a error: Parse error: syntax error, unexpected ';'
otherwise you can comment the code on line 13 below thnx!
awesome tuts :). Keep it up bro
ОтветитьThe code was working on my users table but not on the other. I don't know why. I tried to echo the $sqlInsert and run to phyMyAdmin it works but not in the php code.
Ответить