Jump to content

Fabio_Siqueira

New Members
  • Posts

    4
  • Joined

  • Last visited

Fabio_Siqueira's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys!! I want to build a function that read and save csv file in MySql. The problem is that I can't pass the while array in function 'cause i want to change the variable $sql sometimes just to reduce my code in the future. Ex: function connect(){ @mysql_connect("localhost", "root", ""); mysql_select_db("school"); } function import($sql=null){ $filename = $_GET['file']; $openfile = fopen($filename, "r"); while(($row = fgetcsv($openfile,2048,";"))!==FALSE) { mysql_query($sql) or die(mysql_error()); } fclose($openfile); } $report = "Insert into table (DocumentoSD,Descricao,Cod_Client,Cliente) values('$row[0]','$row[1]','$row[2]','$row[3]')"; connect(); Import($report);
  2. Hello guys!! I want to build a function that read and save csv file in MySql. The problem is that I can't pass the while array in function 'cause i want to change the variable $sql sometimes just to reduce my code in the future. Ex: function connect(){ @mysql_connect("localhost", "root", ""); mysql_select_db("school"); } function import($sql=null){ $filename = $_GET['file']; $openfile = fopen($filename, "r"); while(($row = fgetcsv($openfile,2048,";"))!==FALSE) { mysql_query($sql) or die(mysql_error()); } fclose($openfile); } $report = "Insert into table (DocumentoSD,Descricao,Cod_Client,Cliente) values('$row[0]','$row[1]','$row[2]','$row[3]')"; connect(); Import($report);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.