0

i have a problem that i will insert in database mysql from android this information student id - section id -current date -Status each time that user click the buttons it will insert this information in database also i check if the record is duplicate if it is i will told the user you already insert but if not it will insert correctly i try to insert and by change every time the date but it said you already insert how can i solve this problem so i can insert every time a change the date in my database

2
  • a) You're taking user input and using it directly in a query without any escaping or validation. This leaves your database wide open to SQL injection attacks. b) The mysql_* family of functions is deprecated in all but name, and should be avoided. Please look into using mysqli or PDO instead. Commented Oct 27, 2012 at 18:24
  • why i can not insert more the one time even when i change the date it is not insert only one times Commented Oct 27, 2012 at 18:40

1 Answer 1

1

You are only checking, if the user has given input for the fields or not.
And before inserting the record, you are not checking if such record already exists in database or not.
And may be because of unique constraint if any defined, next inserts are rejected with an exception due to data duplication in fresh input from the user.

Check if any constraints are defined for data uniqueness.
Based on them handle exceptions and inform user accordingly.

Sign up to request clarification or add additional context in comments.

7 Comments

Check if any constraints are defined for data uniqueness how can i do it can you help me ?
execute show create table attends; and see what it displays. And show us the same.
i edit some change in my answer look at it if there is other way u can show you creation told me
if you have access to mysql console execute show create table attends; and update your posting with that output. I think phpMyAdmin too supports this execution.
i try to find it but i do know how i do i print screen that may help you to find the option im30.gulfup.com/SLQn1.png
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.