I have a script that takes a CSV file and uploads every line in a database However, Letters do not show inaccurate, but do not display at all.
For example, there is an "Input" row here, and it must be read in the database:
"This cafe is amazing", "1000", "www. Example.com "" This CAF "," 1000 "," www.example.com "
is the script that uploads:
header ("Content-type: text / plain; charset = UTF-8"); If (! Isset ($ _ POST ['form_id'])) {header ("location: .error.form_id"); Go out(); } $ Form_id = $ _POST ['form_id']; $ Csv = $ _FILES ['csv_file']; If ($ csv ['size']> gt; {$ handle = fopen ($ csv ['tmp_name'], "r") require_once ("db.php"); $ I = (! Isset ($ _ POST) ['Csv_headers']) 1: 0;; ($ data = fgetcsv ($ handle, 1000,', ',' '')) {if ($ i> gt; 0) {$ data [2] = str_replace (Straps ($ data [3], "http") === False & amp; $ data [3]! = "") {$ Data ("+", "+", $ data [2]); [3] = "http: //" $ data [3];} mysql_query ("INSERT display_list SET form_id = $ form_id, company_name = '". Addlashes ($ data [0]). "', Country = '" Adds $ ("$ data [1]).", "Stand_Number = '". ($ Data [2]). "', Web_address = '". ($ Data [3]). Logo_file = '". (Results $ data [4])" ", added_data = B () ");} $ i ++;}} and {header (" location: ./?error=csv_file "); exit ();} mysql_close (); header (" location: ./
Even when setting content type header ()
, I get a problem.
Save the CSV file in UTF 8 before uploading it.
No comments:
Post a Comment