Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import excel to mysql unicode issue

    Guys

    i have a script which you can view below that will import a .csv file into a mysql table, however i get errors due to the various special characters in the spreadsheet. is there anyway i can get around this.

    PHP Code:

    <?php 
    $fs 
    filesize("file.csv");  

    $fh fopen("file.csv""r");  

    fgets($fh$fs);  
    require (
    'db.php'); 
        while(
    $row fgetcsv($fh$fs))   
             
            {  
             
            
    $category_id $row["0"];              
            
    $category $row["1"];  
            
    $manufacturer_id $row["2"];  
            
    $manufacturer $row["3"];      
            
    $product_name $row["4"];  
            
    $info_text$row["5"]; 
            
    $features$row["6"]; 
            
    $specification $row["7"]; 
            
    $image_name $row["8"]; 
            
    $data_sheet $row["9"]; 
            
    $buy_price $row["10"]; 

    $query "INSERT into test.test (category_id, category, manufacturer_id, manufacturer, product_name, info_text, features, specification, image_name, data_sheet, buy_price) values ('$category_id', '$category', '$manufacturer_id', '$manufacturer', '$product_name', '$info_text', '$features', '$specification', '$image_name', '$data_sheet', '$buy_price')"

    $result mysql_query ($query) or die (mysql_error()); 

    }  

    ?>
    thanks in advance

  • #2
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just fixed it, as it was only one character causing problems i replaced it with another before the insert then replaced to the original character when selec ting the data.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •