Database Code

  Home arrow Database Code arrow Converting CSV Files to MySQL Insert Q...
DATABASE CODE

Converting CSV Files to MySQL Insert Queries Using PHP
By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2010-06-16

    Table of Contents:
  • Converting CSV Files to MySQL Insert Queries Using PHP
  • How to create the CSV file from the Local host MySQL database
  • Actual Form HTML Source Code
  • The PHP script to process form inputs

  •  
     

    SEARCH CODEWALKERS

    Converting CSV Files to MySQL Insert Queries Using PHP


    (Page 1 of 4 )

    This article covers an important web application tool written in PHP that will let developers upload a CSV file and then convert that to MySQL insert queries.

    This is particularly useful in a limited hosting environment where a user is restricted to importing or uploading an SQL file to the MySQL server. Converting the csv file (that contains the data) to MySQL insert queries makes it easy to transfer the data to MySQL server without doing any uploads (which are restricted).

    Creation of the CSV file and the Initial Code

    At the start of the script, it would be nice to declare the sessions (used for checking the security code submitted by the user versus the correct answer stored in a session variable) and turn off all PHP warnings that will be displayed to the web browser. This is not good to look at for the production server.

    <?php

    session_start();

    error_reporting(0);

    ?>

    Then the followed by the header portion HTML:

    <HTML>

    <HEAD>

    <TITLE>Convert CSV to SQL insert queries tool</TITLE>

    </HEAD>

    <BODY>

    <font face="Courier" size="2">

    </head>

    <body>

    <H2>CSV to MySQL</H2>

    Background:

    <br /><br />

    More Database Code Articles
    More By Codex-M

    blog comments powered by Disqus

    DATABASE CODE ARTICLES

    - Converting CSV Files to MySQL Insert Queries...
    - Examples and Tools for Database Design
    - Relationships, Entities and Database Design
    - Modeling and Designing Databases
    - Data extract to Excel
    - Oracle database class 0.76
    - The opposite of mysql_fetch_assoc
    - On line Thermal Transmitance Calculation
    - pjjTextBase
    - PHP Object Generator
    - FastMySQL
    - RC4PHP
    - SQL function with integrated sprintf()
    - DB Interaction Classes v1.1
    - deeMySQLParser

    Developer Shed Affiliates

     



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