ladykudos Posted November 21, 2010 Share Posted November 21, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/219389-code-inserting-unwanted-blank-record-into-database/ Share on other sites More sharing options...
GKWelding Posted November 22, 2010 Share Posted November 22, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/219389-code-inserting-unwanted-blank-record-into-database/#findComment-1137877 Share on other sites More sharing options...
ladykudos Posted November 28, 2010 Author Share Posted November 28, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/219389-code-inserting-unwanted-blank-record-into-database/#findComment-1140698 Share on other sites More sharing options...
jcbones Posted November 29, 2010 Share Posted November 29, 2010 Use mysql_real_escape_string() to help sanitize your data for mysql interaction. Quote Link to comment https://forums.phpfreaks.com/topic/219389-code-inserting-unwanted-blank-record-into-database/#findComment-1140741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.