0
if(isset($_POST['submit']))
{

    $file=$_FILES['file']['tmp_name'];
    $handle=fopen($file,"r");

    while(($r=fgetcsv($handle,"500",",")) !==FALSE)
    {

    $sql=mysqli_query($con,"insert into `` values('" . implode("','",$r) . "')") or die(mysql_error()) ;

        //echo implode("','",$r); if i run this it shows the data of csv file
    }
}

Query is not working. It only shows blank page.

20
  • 1
    First of all you mix mysql_ API and mysqli_ API. Change: mysql_error() to mysqli_error(). Then you get the error message Commented Oct 13, 2016 at 7:39
  • 1
    What about this here: insert into ''? Commented Oct 13, 2016 at 7:39
  • 1
    Second one you have to add a tablename between yout backticks: insert into <table_name> Commented Oct 13, 2016 at 7:39
  • @Jens done these thing but still no luck Commented Oct 13, 2016 at 7:41
  • @A.R Do you get an error message now? Commented Oct 13, 2016 at 7:42

1 Answer 1

1

insert into `` values

table name is missing, moreover parse the data, make sure the data that you insert is correct, this can lead to mysql injection as you are passing parameters in the sql statement directly.

Sign up to request clarification or add additional context in comments.

2 Comments

inserted the name of the table and fix the mysql_error() to mysqli_error().. Still no luck
did you check the record? use try catch

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.