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.GordonM– GordonM2012-10-27 18:24:28 +00:00Commented 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 timessara– sara2012-10-27 18:40:41 +00:00Commented Oct 27, 2012 at 18:40
Add a comment
|
1 Answer
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.
7 Comments
sara
Check if any constraints are defined for data uniqueness how can i do it can you help me ?
Ravinder Reddy
execute
show create table attends; and see what it displays. And show us the same.sara
i edit some change in my answer look at it if there is other way u can show you creation told me
Ravinder Reddy
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.sara
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
|