Hey all,
I want to import data into mysql Database without using Com object using php technique from a Microsoft Excel File?
5 6445 Dormilich 8,658
Recognized Expert Moderator Expert
at first glance I'd say that's impossible, you have to read the file format somehow (and since it's a proprietary format…).
Yeh but you can see that
PHP MyAdmin give the option of importing data through Excel File without using Com object. Is there any special technique PHPMyadmin Using or PHPMYadmin has it's own algorithm.
Dormilich 8,658
Recognized Expert Moderator Expert
this is beyond my skill level…
Ciary 247
Recognized Expert New Member
Step1 Form: save it as enterfile.php -
-
<form method="post" enctype="multipart/form-data" action="import.php">
-
<table width="628" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#eeeeee">
-
<tr>
-
<td width="219"><font size=3><b>Selectionner votre fichier *.csv :</b></font></td>
-
<td width="244" align="center"><input type="file" name="userfile" value="userfile"></td>
-
<td width="137" align="center">
-
<input type="submit" value="Envoyer" name="envoyer" >
-
</td>
-
</tr>
-
</table>
-
</form>
-
Step2 create connect script: save it as connect.php -
<?php
-
// paramètres de connexion
-
$hostname_smoby = "localhost"; /
-
$database_smoby = "sample";
-
$username_smoby = "root";
-
$password_smoby = "";
-
$db = mysql_connect($hostname_smoby, $username_smoby, $password_smoby) or trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database_smoby)or trigger_error(mysql_error(),E_USER_ERROR);
-
?>
-
Step 3 import.php -
<a name="haut"></a>
-
<?php
-
// vérification sur la session authentification (la session est elle enregistrée ?)
-
// ici les éventuelles actions en cas de réussite de la connexion
-
require_once('connect.php');
-
//===========================================================
-
//
-
// Code de : Xavier Manzoni
-
// Email : kaptain_kavern_23@hotmail.com
-
// Date: 23 Novembre 2004
-
// Objectif :
-
// Selection d'un fichier xls enregistre sous format
-
// CSV (separateur ";") puis enregistrement dans la base.
-
// Base: smoby
-
// Table: bdd
-
//===========================================================
-
-
-
//=========================
-
// Traitement des donnees
-
//=========================
-
-
//recupere le nom du fichier indiqué par l'user
-
$fichier=$_FILES["userfile"]["name"];
-
-
// ouverture du fichier en lecture
-
if ($fichier)
-
{
-
//ouverture du fichier temporaire
-
$fp = fopen ($_FILES["userfile"]["tmp_name"], "r");
-
}
-
else{
-
// fichier inconnu
-
?>
-
<p align="center" >- Importation échouée -</p>
-
<p align="center" ><b>Désolé, mais vous n'avez pas spécifié de chemin valide ...</b></p>
-
<?php
-
exit();
-
}
-
// declaration de la variable "cpt" qui permettra de conpter le nombre d'enregistrement réalisé
-
$cpt=0;
-
-
// importation
-
while (!feof($fp))
-
{
-
$ligne = fgets($fp,4096);
-
// on crée un tableau des élements séparés par des points virgule
-
$liste = explode(";",$ligne);
-
// premier élément
-
$liste[0] = ( isset($liste[0]) ) ? $liste[0] : Null;
-
$liste[1] = ( isset($liste[1]) ) ? $liste[1] : Null;
-
$liste[2] = ( isset($liste[2]) ) ? $liste[2] : Null;
-
$liste[3] = ( isset($liste[3]) ) ? $liste[3] : Null;
-
-
$champs0=$liste[0];
-
$champs1=$liste[1];
-
$champs2=$liste[2];
-
$champs3= $liste[3];
-
-
-
// pour eviter qu un champs "nom" du fichier soit vide
-
if ($champs1!='')
-
{
-
// nouvel ajout, compteur incrémenté
-
$cpt++;
-
// requete et insertion ligne par ligne
-
// champs1 id en general dc on affecte pas de valeur
-
-
$result= mysql_query("INSERT INTO names VALUES('','$champs0','$champs1','$champs2','$champs3')");
-
-
}
-
}
-
-
// fermeture du fichier
-
fclose($fp);
-
-
-
//==================
-
// FIN
-
//==================
-
?>
-
<br /><br />Nombre de valeurs nouvellement enregistrées: <b><?php echo $cpt;?></b>.<br /><br />
-
I wish that help sorry for the frensh explaination inside the php scripts . it was just fast reply .have funn with php
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a table in MySQL with the path & filename to
the image.
I have successfully uploaded and performed an update query on the database,
but the problem I have is I cannot retain the primary key field in a
variable which is then used in a SQL update...
|
by: Damien |
last post by:
Hi to all,
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is something like :id,text1html,
text1raw,... .
Problems :
1. Texts can contain html tags, including entities (" etc), so
using only the ';' as separator does not work.
2. Some line are so long that is appears php breaks them down, so I lose
|
by: jet |
last post by:
Hi,
Maybe this is an easy task, but I'm having a really hard time figuring
out how to do this. I'm a complete newbie to SQL Server.
I have a database dump file from MySQL that's in .sql format. I'm
trying to figure out how to import that into SQL Server 2000 so that
I'll be able to manipulate it in a gui format, rather than command
line. I can't find any import that takes a .sql file. I've been
trying to load it into the query...
|
by: news |
last post by:
Our production database in an exported textfil runs about 60 MB.
Compressed that's about 9 MB.
I'm trying to import the export into another machine running FC3 and
mySQL 11.18, and it appears as though the file may be too big!
When I try to do it via command line:
mysql -u root --host=localhost printing < ./printing.txt
It eventually errors out with a "syntax error on line X" and only about
|
by: phillip.s.powell |
last post by:
We're looking at a GUI interface for our MySQL DB and I am interested
in MySQL Administrator, however, one of our requirements is to be able
to import/export databases. Is this possible or do I need to know else
(e.g. Navicat)?
Thanks
Phil
| |
by: Avi |
last post by:
Hi
I need to read in a large set of text files (9GB+ each) into a database
table based on fixed width lengths.
There are several ways to complete this, but I am wondering if anyone has
insight into the FASTEST way to read in the data and chop it up ahead of
posting it into the DB.
So far, things work, but they are far slower than expected.
|
by: NewbieSupreme |
last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x,
which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a
table to a text file, tab-delimited, text qualifyer of "none" (this is how I
read to do it from newsgroups).
When I use the Query window in phpmyadmin to import the text file, it waits
a while, then returns an error:
#1064 - You have an error in your SQL syntax; check the manual that...
|
by: Randy |
last post by:
Folks:
We have a web-based app that's _really_ slowing down because multiple
clients are writing their own private data into a single, central
database. I guess the previous programmer did things this way because it
made things easy. Well, I'm the person that has to put up with
the long-term headache.
Anywho, someone at work wants things sped up, so what I'm looking
at doing is this for each client:
|
by: GarryJones |
last post by:
(I am sorry if this is the wrong group for this posting, I cant find a
group on usenet for phpmyadmin, but maybe someone would be nice enough
to answer me anyway....)
I need to import data into a simple table The table has three fields.
The first is an auto increment value, the second the current time and
date (the 14 character version), and a field with some data.
This works okay in SQL mode
INSERT INTO all_epst VALUES...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |