Ask a Question related to PHP Development, Design and Development.
-
Richard Sauve #1
insert CSV in mySql problem
Hi,
The script below add twice the same line from de CSV in the DB,
Is there something I am missing...
-------
$link = mysql_connect("localhost","","");
$selection = mysql_select_db("table", $link);
$line = array();
$fclients = fopen("file.csv","r");
while ($line = fgetcsv($fclients, 1500, ",")) {
$name_cie = addslashes(trim($line[0]));
$adress = addslashes(trim($line[1]));
$tel = addslashes(trim($line[3]));
$fax = addslashes(trim($line[4]));
$mail = addslashes(trim($line[5]));
$name = addslashes(trim($line[6]));
$title = addslashes(trim($line[7]));
$site = addslashes(trim($line[8]));
}
$request = "INSERT INTO contact
(name_cie,adress,tel,fax,mail,name,title,site,desc ription)";
$request .= "VALUES
('$name_cie','$adresse','$tel','$fax','$mail','$na me','$title','$site','$des
cription')";
$result = mysql_query($request) or DIE("Error: " . mysql_error()) ;
-------
Any help would be appreciated.
R. Sauve
Richard Sauve Guest
-
Problem With Insert into MySQL DB using VB.Net 2005
Hello everyone, I am having a issue inserting values into a MYSQL table, and for the life of me, I can figure out why. I know the connection is... -
MySql insert question.
hi all thanks again for all th direction you guys have given me in the past and hopefully now.. i have a partial backend done for uploading... -
id after insert in MySQL
I'm trying to obtain the id of an INSERTed MySQL record (which is set as AUTO INCREMENT in my table btw). I believe the php function is... -
insert combobox into MySQL db
I cant seem to figre this out nor can i find an example of it: how to insert the value of the combox to the dB. this is what I have got so far: ... -
php problem array insert into mysql
I am having trouble inserting my array into mysql db. Everything else is working except for the insert into the DB. I've read through many of the... -
Milambar #2
Re: insert CSV in mySql problem
Richard Sauve wrote:
If its a simple csv file, why not just use the MySQL command "IMPORT" to> Hi,
>
> The script below add twice the same line from de CSV in the DB,
> Is there something I am missing...
>
> -------
> $link = mysql_connect("localhost","","");
> $selection = mysql_select_db("table", $link);
> $line = array();
> $fclients = fopen("file.csv","r");
> while ($line = fgetcsv($fclients, 1500, ",")) {
> $name_cie = addslashes(trim($line[0]));
> $adress = addslashes(trim($line[1]));
> $tel = addslashes(trim($line[3]));
> $fax = addslashes(trim($line[4]));
> $mail = addslashes(trim($line[5]));
> $name = addslashes(trim($line[6]));
> $title = addslashes(trim($line[7]));
> $site = addslashes(trim($line[8]));
> }
> $request = "INSERT INTO contact
> (name_cie,adress,tel,fax,mail,name,title,site,desc ription)";
> $request .= "VALUES
> ('$name_cie','$adresse','$tel','$fax','$mail','$na me','$title','$site','$des
> cription')";
> $result = mysql_query($request) or DIE("Error: " . mysql_error()) ;
> -------
>
> Any help would be appreciated.
>
> R. Sauve
>
>
>
import it?
Milambar Guest



Reply With Quote

