Link to home
Start Free TrialLog in
Avatar of craigneil
craigneil

asked on

Coldfusion Bugs Won't Insert all fields

I have a simple cfform which uses cfinsert to write to MYSQL.  Too bad it's not as simple as you would think.  Sometimes the all data is written to the DB, sometimes it's not.  There are no errors. All I am attempting to INSERT is simple text. Why would it work sometimes, and not others?
Avatar of twalgrave
twalgrave

You might try posting the code that shows the DB inserts.  

Frequently inserts do not happen because of:
1) errors, you indicate there are none
2) permissions, but if they sometimes work to the same table, then this probably isn't your issue
3) Failure to issue the update statements required if you are using them
4) Failure to commit a transaction
5) You are never actually issuing the command (the code never falls into the statement because it does not meet conditional criteria.
Avatar of craigneil

ASKER

Form:
<cfform action="process2.cfm">
                                            <div class= "req">*First Name:*</div>
                            <td bgcolor="638ACE">
                              <cfinput name="firstname" size="15" maxlength="50" required="yes" message="!You Must Fill in Your FIRST NAME!">
                            </td>
                            <td bgcolor="638ACE"><div class="req">*Last Name:*</div>
                            </td>
                            <td bgcolor="638ACE"><cfinput name="lastname" size="15" maxlength="50" required="yes" message="!You Must Fill in Your LAST NAME!">
                            </td>
                          <tr>
                            <td>
                              <div class="re">Co - First Name:</div>
                            </td>
                            <td><cfinput name="cofirstname" size="15" maxlength="50">
                            </td>
                            <td><div class="re">Co - Last Name:</div>
                            </td>
                            <td><cfinput name="colastname" size="15" maxlength="50">
                            </td>
                          </tr>
                          <tr>
                            <td bgcolor="638ACE">
                              <div class="req">*Day Phone:*</div>
                            </td>
                            <td bgcolor="638ACE"><cfinput name="dayphone" size="15" maxlength="20" required="yes" message="!You must fill in your DAYTIME PHONE NUMBER!">
                            </td>
                            <td bgcolor="638ACE"><div class="re">Evening Phone:</div>
                            </td>
                            <td bgcolor="638ACE"><cfinput name="eveningphone" size="15" maxlength="20">
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <div class="re">Best Time to Call:</div>
                            </td>
                            <td>
                              <cfinput type="radio" name="besttime" value="day">
            Day
            <cfinput type="radio" name="besttime" value="evening">
            Evening </td>
                            <td><div class="re">Email Address:</div>
                            </td>
                            <td>
                              <cfinput name="email" size="15" maxlength="75">
                            </td>
                          </tr>
                          <tr>
                            <td bgcolor="638ACE">
                              <div class="req">*Street Address:*</div>
                            </td>
                            <td bgcolor="638ACE"><cfinput name="address" size="15" maxlength="100" required="yes" message="!You must fill in your STREET ADDRESS!">
                            </td>
                            <td bgcolor="638ACE"><div class="req">*City:*</div>
                            </td>
                            <td bgcolor="638ACE"><cfinput name="city" size="15" maxlength="50" required="yes" message="!You must fill in your CITY!">
                            </td>
                          </tr>
                          <tr>
                            <td>
                             
      <div class="req"></div>
    </td>
    <td>&nbsp; </td>
    <td>
      <div class="req">*Zip Code:*</div>
    </td>
    <td>
      <cfinput name="zipcode" size="10" maxlength="10" required="yes" message="!You must fill in your ZIPCODE!">
    </td>
  </tr>
  <tr>
    <td bgcolor="638ACE">
      <div class="req"></div>
    </td>
    <td bgcolor="638ACE">&nbsp;</td>
    <td bgcolor="638ACE">&nbsp;</td>
    <td bgcolor="638ACE">&nbsp;</td>
  </tr>
  <tr>
    <td>
      <div class="req"></div>
    </td>
    <td>&nbsp;</td>
    <td>&nbsp; </td>
  </tr>
  <tr>
    <td bgcolor="638ACE">
      <div class="req"></div>
    </td>
    <td bgcolor="638ACE">&nbsp;</td>
    <td bgcolor="638ACE">
      <div class="req"></div>
    </td>
  </tr>
  <tr>
    <td bgcolor="638ACE">&nbsp;</td>
    <td bgcolor="638ACE">&nbsp;</td>
  </tr>
  <tr>
    <td>
      <div class="req">Annual Income: </div>
    </td>
    <td>
      <cfinput name="income"  size="15">
    </td>
    <td>
   
    </td>
    <td>
     
    </td>
  </tr>
  <tr>
    <td colspan="4" bgcolor="638ACE">
      <div align="center"><font color="003366" size="2">
        <input type="submit" value="Submit">
        <br>
        <b><font color="#FFFF00">*Required Fields Are Marked in Yellow*</font></b></font></div>
</cfform>


Process2.cfm:
<cfset Form.adddate = (now())>
<cfset Form.source = (1)>
<cfinsert datasource="TESTING" tablename="application">
<cflocation url="thank_you.html">
ASKER CERTIFIED SOLUTION
Avatar of twalgrave
twalgrave

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CFINSERT is too fickle to allow it to determine the form fields without specifying any.  I tried this code, and it works much better, with zero data loss:

<cfinsert datasource="#DATASOURCE#" tablename="application" formfields="#form.fieldnames#, adddate, source">

That's just what is said in the link I provided.  Can you accept my answer then?  You do that by going to the link to the right of my comment named "Accept Comment as Answer" and assigning an appropriate grade.  Thanks.
I didn't use your info to get my answer. Do you still think I should give you the points?
That's entirely up to you my friend.  All I really care about is that this question, since it now has an answer, is finalized one way or the other.  The other way (other than awarding the points to me) is to post a zero-point question in the community support topic area (found on the left of the page or by clicking here: https://www.experts-exchange.com/Community_Support/ ) asking for a refund of the points on this question.  Make sure to give the question number (from this URL) or the URL itself: https://www.experts-exchange.com/questions/20534855/Coldfusion-Bugs-Won't-Insert-all-fields.html in the comment section.  Note:  This question should be PAQ'd and not deleted because it does have value since the solution is posted.

Actually, there's a 3rd option (and I don't want this to sound like I'm looking for points, because I really do not care one way or the other).  That option is to post in community support the way mentioned above.  Ask for the question points to be reduced and then accept my answer.

Now I think I've exhausted all the possible options.  I hope this helps you make a decision in how to finalize this question.

Truly, honestly, I would not have any hard feelings if you asked for all your points back.
craigneil:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.