MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2012, 01:55 PM
techker techker is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2005
Posts: 636 techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 10 h 40 m 4 sec
Reputation Power: 15
Import CSV file but gives ""

Hey guys i have a CSV uploader but i don't know what format i should save the xls to CSV ..cause i tryed comma delimited..

when i import to mysql i get "name" ...

what CSV format should i use?

uploader

PHP Code:
if ($_FILES[csv][size] > 0) { 

    
//get the csv file 
    
$file $_FILES[csv][tmp_name]; 
    
$handle fopen($file,"r"); 
     
    
//loop through the csv file and insert into database 
    
do { 
        if (
$data[0]) { 
            
mysql_query("INSERT INTO  $Year (Ecole,N_Fiche,Nom,Prenom,Code_P,Foyer,Secondaire,Annee,Sortie) VALUES 
                ( 
                    '263',
                    '"
.addslashes($data[0])."',
                    '"
.addslashes($data[1])."', 
                    '"
.addslashes($data[2])."',
                    '"
.addslashes($data[5])."',
                    '"
.addslashes($data[6])."',
                    '"
.addslashes($data[4])."',
                    '
$Year',
                    '"
.addslashes($data[7])."' 
                ) 
            "
); 
        } 
    } while (
$data fgetcsv($handle,1000,",","'")); 
    
// 

    //redirect 
    
echo "<meta http-equiv=Refresh content=1;url=Admin.php?success=1>";die; 





Reply With Quote
  #2  
Old October 21st, 2012, 03:04 PM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
Any reason you don't use the LOAD DATA option?
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old October 21st, 2012, 04:58 PM
techker techker is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2005
Posts: 636 techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level)techker User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 10 h 40 m 4 sec
Reputation Power: 15
the code works just as good..LOAD data will do what more?

think its the ".addslashes($data[0])." that adds the """

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Import CSV file but gives ""

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap