Jump to content

Code inserting unwanted blank record into database


ladykudos

Recommended Posts

I have 2 files; Newfault.php and thankyou.php

 

1) Data is entered into a form in Newfault.php

2) The data from this form is retieved in thankyou.php and is then inserted into a table called "Calls"

 

Problem:

 

My entered record is being added to my database OK, but it is also adding a blank record for some reason and I can't work out why. Can anyone help? This is for my uni assignment.

 

Thanks,

 

Ladykudos

 

[attachment deleted by admin]

The php file attached works fine. It was because you where using braces (the {}) to evaluate the variables in the SQL string. I've gotten rid of these and also added in some variable security in the form of mysql_real_escape_string. I have tested this and it definitely does work fine.

 

I did the first test with your code and managed to replicate the error, removing the braces and concatenating the string instead work perfectly, I then just added in the variable escaping as it's bad practice not to.

 

[attachment deleted by admin]

Thanks GK Welding for your reply. I'm afraid I am a novice to PHP so I'm not sure what you mean in your answer. My code does not have any { } curly brackets only straight brackets '( )' so I am rather confused . Also, what's a mysql_real_escape_string ?

 

Can you edit my code and show me what you mean?

Thanks,

Ladykudos

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.