Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-02-2006, 06:41 AM   PM User | #1
bhakti_thakkar
Regular Coder

 
Join Date: Sep 2006
Location: India Mumbai
Posts: 248
Thanks: 13
Thanked 1 Time in 1 Post
bhakti_thakkar is an unknown quantity at this point
Multiple table inserts from CSV file

hi,
i am uploading data from a CSV file and its doing it properly.but the problem is i want to also insert the same data + some new values in the foreign key table which is failing. when i try to print the mysql_insert_id();it prints 0 even though it has taken the next autoincrement value.below is my code

if($this->table_exists)
{
$sql = "LOAD DATA INFILE '".@mysql_escape_string($this->file_name).
"' INTO TABLE `".$this->table_name.
"` FIELDS TERMINATED BY '".@mysql_escape_string($this->field_separate_char).
"' OPTIONALLY ENCLOSED BY '".@mysql_escape_string($this->field_enclose_char).
"' ESCAPED BY '".@mysql_escape_string($this->field_escape_char).
"' ".
($this->use_csv_header ? " IGNORE 1 LINES " : "")
."(`".implode("`,`", $this->arr_csv_columns)."`)";
$res = @mysql_query($sql);
$id = mysql_insert_id();
print "ID===".$id;
$this->error = mysql_error();

}
$this->Flag = "1";

Can any one help me how to do it...
Thanks
Bhakti
bhakti_thakkar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:39 PM.


Advertisement
Log in to turn off these ads.