Insert Into Multiple Tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TKB
    New Member
    • Nov 2006
    • 8

    #1

    Insert Into Multiple Tables

    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 insurancecharge s (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 transportationc harges (Transportation Unit)
    VALUES
    ('$_POST[TransportationU nit]')");
    ?>
  • 1harsh789
    New Member
    • Oct 2006
    • 5

    #2
    you need to change your query as follows:

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

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      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_esca pe_string command when inserting.

      Ronald :cool:

      Comment

      Working...