Hello,
how do create an error statement if the primary key entered into mysql from a php form is already in the mysql table?
how do you do the same check to ensure user enteres a interger?
error checks on data entry into mysql from php forms
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Something like
Code: Select all
$query = "INSERT INTO `table` IF NOT EXISTS (`id`) VALUES ('$value')";
if (mysql_query($query)) {
echo 'Data added to DB';
} else {
echo 'The data could not be added as this value has already been used in the database';