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]

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.