Jump to content

[SOLVED] Intermittent problem with inserting data into MySQL table


Recommended Posts

Hi guys and gals,

 

I'll start out by stating that I'm a newb with PHP, but can get around okay. Throughout all of my searches for specific problems, I have always seen this forum pop up in search results, and usually, I found a solution by reading old threads. Today however, I don't even know what to search for.

 

I'm having a problem with a script I'm working on. Basically, it's a registration form for a dating site, and it is devided into 4 steps. All of the steps are held in one php script, and the proper page is displayed at the correct time. In order to "remember" the data from the previous pages, I register all of the form variables as session variables. Once all 4 pages are filled out, the script then inserts all of the data into a mysql table.

 

The problem I'm having, is that once in a while, someone will create an account, and it will register into the database, but there is only TWO pieces of information that make it in. Everything else is blank. I don't get it. It's as if every session variable was unset before insertion, except for 2. It's really got me stumped. I has happened to a few people, from different computers.

 

I don't even know where to start looking. :S

 

Any help or direction would be greatly appreciated!

 

Thanks so much for your time!

Sounds like maybe your variables are getting overwritten, but without any code, it's hard to say.

 

It sure does look that way, but by going over my script over and over, it would seem impossible for that to happen. Really strange.

 

Thanks for your help!

I figured out the problem. One of the many fields was education, and two of the options were "Master's" and "Bachelor's", both of which contain a single quote. The script never crashed for me, because I never selected either of those in testing. Good thing my Girlfriend is good at testing scripts! Hehehe!

 

A simple addslash() on each of the variables before insertion fixed the problem. I have gotten into the habit of writing code in an magicquotes environment.

 

So incase anyone is looking at this in the future, always clean/filter your data! :)

 

Thanks guys!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.