php-db | 2001072
Date: 07/29/01
- Next message: JD Daniels: "RE: [PHP-DB] 'htaccess" method : how to modify passwords from PHP scripts ?"
- Previous message: Al Savage: "[PHP-DB] Re: Record Update Link"
- Next in thread: olinux: "RE: [PHP-DB] 2 Tables- 1 Insert Problem"
- Reply: olinux: "RE: [PHP-DB] 2 Tables- 1 Insert Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm trying to insert data into two separate tables using 1 INSERT. The code
below represents a first crack at it, but I can't seem to figure out how to
get this to work properly.
Thanks.
Steve
<?
$db_name="testDB";
$table_name1 = "my_contacts";
$table_name2= "company";
$connection = <email protected> ("XXXX","XXXX","XXXXor die ("Couldn't
connect.");
$db = <email protected>($db_name, $connection) or die ("Couldn't select
database.");
$sql_1 = "INSERT INTO $table_name1
(id,fname,lname,address1,address2,address3,postcode,country,prim_tel,sec_tel
,email,birthday)
VALUES
(\"\",
\"$fname\",\"$lname\",\"$address1\",\"$address2\",\"$address3\",\"$postcode\
",
\"$country\",\"$prim_tel\",\"$sec_tel\",\"$email\",\"$birthday\")
";
$sql_2 = "INSERT INTO $table_name2 WHERE my_contacts.company=$companyid
(companyname,website)
VALUES
(\"\",
\"$companyname\",\"$website\")
";
$result = <email protected> ($sql_1,$sql_2,$connection) or die ("Couldn't
execute query.");
?>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: JD Daniels: "RE: [PHP-DB] 'htaccess" method : how to modify passwords from PHP scripts ?"
- Previous message: Al Savage: "[PHP-DB] Re: Record Update Link"
- Next in thread: olinux: "RE: [PHP-DB] 2 Tables- 1 Insert Problem"
- Reply: olinux: "RE: [PHP-DB] 2 Tables- 1 Insert Problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

