By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

Insert Into Multiple Tables

P: 8
I have the following tables/fields, how can I make the insertion into 1? Now as I have the code into different querries there is nothing added in mysql.

Thank you in advance for your help.


mysql_query ("INSERT INTO categories (CategoryName)
VALUES
('$_POST[CategoryName]')");

?>


<?php
mysql_query ("INSERT INTO insurancecharges (InsuranceType)
VALUES
('$_POST[InsuranceType]')");

?>



<?php
mysql_query ("INSERT INTO packaging (PackagingType)
VALUES
('$_POST[PackagingType]')");
?>


<?php
mysql_query ("INSERT INTO products (ProductUnits)
VALUES
('$_POST[ProductUnits]')");
?>

<?php
mysql_query ("INSERT INTO transportationcharges (TransportationUnit)
VALUES
('$_POST[TransportationUnit]')");
?>
Nov 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: 5
you need to change your query as follows:

[PHP]mysql_query ("INSERT INTO categories (CategoryName)
VALUES
('".$_POST[CategoryName]."')");[/PHP]
Nov 30 '06 #2

ronverdonk
Expert 2.5K+
P: 4,258
For your own good: to avoid any SQL injection on your database: never ever store data directly from the outside (e.g. $_POST) into your database. Doing that is the quickest way to get your db corrupted. Always sanitize outside data and always use the mysql_real_escape_string command when inserting.

Ronald :cool:
Nov 30 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.