Forum Moderators: open

Message Too Old, No Replies

Empty records in my table - that shouldn't be empty

Don't know what's going on - should I use Transactions?

         

neophyte

4:12 am on Feb 6, 2008 (gmt 0)

10+ Year Member



Hello All -

Here's some background on my issue:

I've built a web application with a section which accepts job applications. This application "section" is 6 pages long. Before a user can go to the next page, all data from the submitted page is validated so that all required form fields are appropriately filled in. If required information has not been input, the page re-displays with warnings.

When a page HAS been successfully completed, all data from that page is held in php $_Session vars.

When the 6th page is submitted, all $_Session vars that DO contain text input gets processed by the mysql_real_escape_string() function. Those session Vars that are empty get a value of 'NULL'. After that happens, everything gets inserted into the db table.

There's essential functional background. I've tested this application locally with 10 fictitious applicants and on my dev environment, everything worked out okay - everything gets inserted into the proper fields in the proper db table.

Now, the problem:

So, after testing, I put my code and the db live so my client could begin inputting historical applicant data. They just finished inputting 75 applicants, but when I checked the DB, some rows were completely empty - Not many... about 12 out of the 75 entered... but that's enough to freak me out. I'm freaked because - as previously mentioned - you cannot go to the next page without the user providing required input on the preceding page.

Has anyone else had this experience?

I don't know where to start to look. Could it be that I need to use Transactions to make sure everything is submitted correctly from one record before another record is inserted? Another weird thing is that my client told me that he only had one person inputing this data... so it's not like more than one record was being inserted at any one time (at this point).

I'm really confused and nervous about this problem... could someone please give me some advice?

Neophyte

jtara

4:21 am on Feb 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Doesn't sound like a database problem.

Something ahead of the write is making your fields all nulls. I'd suspect the validation.

This points-out a logic flaw, in any case. It doesn't make sense to accept all nulls. There surely must be SOME mandatory fields.

I'd re-post to the PHP forum.

ZydoSEO

12:03 pm on Feb 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I agree w/ jtara... Doesn't sound like a DB problem. However, if you have fields that you feel should always be answered you can define them as NOT NULL in the DB. This will cause your DB to throw an error anytime your code attempts to write a row w/ those fields as NULL values.

Are you checking the return status of your inserts to see if it returns any type of error status? Might want to log the actual INSERT statement(s) you're executing right before you issues it as well as any errors that might occur to a flat logfile so that you can review later. Could be that one particular field when left blank or answered a particular way causes your INSERT statement that you build to be invalid. Have you tried entering single quotes (') and other special characters, for instance, in your string fields to see if they are being handled correctly before writing to the DB?

neophyte

8:27 am on Feb 7, 2008 (gmt 0)

10+ Year Member



jtara and ZydoSEO -

Thanks for weighing-in. Yeah, now that I've re-reviewed the code I believe that you're both right regarding that it is some kind of logic problem on my side.

Appreciate your advice and guidance - back to the code!

Neophyte