How to Post Javascript to a MySQL Database
<p>I have created a form in HTML and I m trying to post the information in the form to a MySQL database. My form makes use of a dynamic list selection that needs to be captured to the database. However when submitting the form I get the following error</p>

<p>Error: Unknown column 'coulmn_name' in 'field list'.</p>

<p>Here is my HTML code for the form</p>

<pre><code>    &lt;td height="94"&gt;&lt;p align="justify"&gt;CALL TRACKER - ADMIN&lt;/p&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
    &lt;table width="36%" border="0" align="center" cellpadding="2" cellspacing="0"&gt;
        &lt;tr&gt;
        &lt;td width="29%" align="right" valign="middle"&gt;&lt;strong&gt;Customer Name :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;
        &lt;input type="text" name="customer_name" width="70%" align="left" valign="middle"&gt;
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td width="29%" align="right" valign="middle"&gt;&lt;strong&gt;E-Mail Address :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;
        &lt;input type="text" name="customer_email_address" width="70%" align="left" valign="middle"&gt;
        &lt;/td&gt;

        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;td width="29%" align="right" valign="middle"&gt;&lt;strong&gt;Case Number :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;
        &lt;input type="text" name="case_number" width="70%" align="left" valign="middle"&gt;
        &lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
        &lt;td width="29%" align="right" valign="middle"&gt;&lt;strong&gt;MSISDN :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;
        &lt;input type="text" name="msisdn" width="70%" align="left" valign="middle"&gt;
        &lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;      
        &lt;td width="29%" align="right" valign="middle"&gt;
        &lt;strong&gt;Route Cause :&lt;/strong&gt;&lt;/td&gt;
        &lt;td width="71%" align="left" valign="middle"&gt;
        &lt;select name="route_cause" id="category" onChange="javascript: listboxchange1(this.options[this.selectedIndex].value);"&gt;
                &lt;!-- &lt;select name="route_cause" id="route_cause"&gt; --&gt;
            &lt;option value=""&gt;Select the Call Reason&lt;/option&gt;
            &lt;option value="Billing Admin"&gt;Billing Admin&lt;/option&gt;
            &lt;option value="Customer Care"&gt;Customer Care&lt;/option&gt;
            &lt;option value="Insurance"&gt;Insurance&lt;/option&gt;
            &lt;option value="Repairs"&gt;Repairs&lt;/option&gt;
            &lt;option value="SIM Swap"&gt;SIM Swap&lt;/option&gt;
            &lt;option value="UTI"&gt;UTI&lt;/option&gt;

        &lt;/select&gt;
        &lt;/td&gt;
      &lt;/tr&gt;



    &lt;tr&gt;
        &lt;td align="right" valign="middle"&gt;
        &lt;strong&gt;Call Type/Indexed To :&lt;/strong&gt;&lt;/td&gt;
        &lt;td align="left" valign="middle"&gt;
        &lt;script type="text/javascript" language="javascript" name="calltype_indexedto"&gt;
                &lt;!--
                    document.write('&lt;select name="subcategory1" onChange="javascript: listboxchange2(this.options[this.selectedIndex].value);"&gt;&lt;option value=""&gt;&lt;/option&gt;&lt;/select&gt;')
                    --&gt;
        &lt;/script&gt;
        &lt;/td&gt;



    &lt;/tr&gt; 




     &lt;tr&gt;
        &lt;td align="right" valign="middle"&gt;
        &lt;strong&gt;Type/TAT :&lt;/strong&gt;&lt;/td&gt;
        &lt;td align="left" valign="middle"&gt;
        &lt;script type="text/javascript" language="javascript" name="type_tat"&gt;
                &lt;!--
                    document.write('&lt;select name="subcategory2" onChange="javascript: listboxchange3(this.options[this.selectedIndex].value);"&gt;&lt;option value=""&gt;&lt;/option&gt;&lt;/select&gt;')
                    --&gt;
        &lt;/script&gt;
        &lt;/td&gt;



    &lt;/tr&gt; 



    &lt;tr&gt;      
    &lt;td width="29%" align="right" valign="middle"&gt;
        &lt;strong&gt;Escalated To :&lt;/strong&gt;&lt;/td&gt;
        &lt;td width="71%" align="left" valign="middle"&gt;
        &lt;select name="escalatedto" id="escalated_to"&gt;
            &lt;option value=""&gt;Select the Escalation&lt;/option&gt;
            &lt;option value="Billing Ops"&gt;Billing Ops&lt;/option&gt;
            &lt;option value="Resolvers"&gt;Resolvers&lt;/option&gt;
            &lt;option value="Finance"&gt;Finance&lt;/option&gt;
            &lt;option value="Ressolver"&gt;Ressolver&lt;/option&gt;
            &lt;option value="Nudebt"&gt;Nudebt&lt;/option&gt;
            &lt;option value="Transunion"&gt;Transunion&lt;/option&gt;
            &lt;option value="N/A"&gt;N/A&lt;/option&gt;


        &lt;/select&gt;
        &lt;/td&gt;
      &lt;/tr&gt;


        &lt;tr&gt;      
    &lt;td width="29%" align="right" valign="middle"&gt;
        &lt;strong&gt;Requested By :&lt;/strong&gt;&lt;/td&gt;
        &lt;td width="71%" align="left" valign="middle"&gt;
        &lt;select name="requestedby" id="requested_by"&gt;
            &lt;option value=""&gt;UTI Requested By&lt;/option&gt;
            &lt;option value="Billing"&gt;Billing&lt;/option&gt;
            &lt;option value="Customer Service"&gt;Customer Service&lt;/option&gt;
            &lt;option value="Insurance"&gt;Insurance&lt;/option&gt;
            &lt;option value="Management"&gt;Management&lt;/option&gt;
            &lt;option value="Repairs"&gt;Repairs&lt;/option&gt;
            &lt;option value="Retail Support"&gt;Retail Support&lt;/option&gt;
            &lt;option value="Retentions"&gt;Retentions&lt;/option&gt;
            &lt;option value="SIM Swap"&gt;SIM Swap&lt;/option&gt;
            &lt;option value="WOW"&gt;WOW&lt;/option&gt;
            &lt;option value="N/A"&gt;N/A&lt;/option&gt;


        &lt;/select&gt;
        &lt;/td&gt;
     &lt;/tr&gt;  


    &lt;tr&gt;      
    &lt;td width="29%" align="right" valign="middle"&gt;
        &lt;strong&gt;Province :&lt;/strong&gt;&lt;/td&gt;
        &lt;td width="71%" align="left" valign="middle"&gt;
        &lt;select name="province" id="province"&gt;
            &lt;option value=""&gt;Select the Province&lt;/option&gt;
            &lt;option value="Eastern Cape"&gt;Eastern Cape&lt;/option&gt;
            &lt;option value="Gauteng"&gt;Gauteng&lt;/option&gt;
            &lt;option value="Kwa-Zulu Natal"&gt;Kwa-Zulu Natal&lt;/option&gt;
            &lt;option value="Limpopo"&gt;Limpopo&lt;/option&gt;
            &lt;option value="Mpumalanga"&gt;Mpumalanga&lt;/option&gt;
            &lt;option value="North West"&gt;North West&lt;/option&gt;
            &lt;option value="Northern Cape"&gt;Northern Cape&lt;/option&gt;
            &lt;option value="Polokwane"&gt;Polokwane&lt;/option&gt;
            &lt;option value="Western Cape"&gt;Western Cape&lt;/option&gt;
            &lt;option value="Other"&gt;Other&lt;/option&gt;
        &lt;/select&gt;
        &lt;/td&gt;
      &lt;/tr&gt;

        &lt;tr&gt;
        &lt;td width="29%" align="right" valign="middle"&gt;&lt;strong&gt;Comments :&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;
        &lt;textarea rows ="5" cols="30" name="comments"&gt;
        &lt;/textarea&gt;
        &lt;/td&gt;
        &lt;/tr&gt;


      &lt;tr&gt;
        &lt;td&gt;
        &lt;p&gt;
          &lt;input type="reset" value="Reset Form"&gt;&lt;input type="Submit" value="Submit"&gt;

Here is my PHP code to write to the Database



    &lt;?php
    $con = mysql_connect("hostname"
    ,"mysqusername"
    ,"mysqlpassword");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("databasename", $con);

    $sql="INSERT INTO customer_services_tracker 
    (customer_name
    ,customer_email_address
    ,case_number
    ,msisdn
    ,route_cause
    ,calltype_indexedto
    ,type_tat
    ,escalatedto
    ,requestedby
    ,province
    ,comments
    )

    VALUES
    ('$_POST[customer_name]'
    ,'$_POST[customer_email_address]'
    ,'$_POST[case_number]'
    ,'$_POST[msisdn]'
    ,'$_POST[route_cause]'
    ,'$_POST[calltype_indexedto]'
    ,'$_POST[type_tat]'
    ,'$_POST[escalatedto]'
    ,'$_POST[requestedby]'
    ,'$_POST[province]'
    ,'$_POST[comments]')";

    $CatName = $rowCat["Name"];

    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added";

    mysql_close($con)
    ?&gt; 
</code></pre>
