MySQL Returning an error if insert value is not unique

0 votes
asked Mar 16, 2016 by rollinsoni (1,020 points)
I would like error to be outputted on addStudent. php page if combination of firstname and last name are in Student table.

4 Answers

–1 vote
answered Jun 2, 2016 by rasnake_To (430 points)
selected Jun 3, 2016 by Gb3371
Best answer
Although this is very old question i found something easier to handle this task. If now just replace one of them with the other
commented Jun 3, 2016 by to_than (600 points)
You can read more here
+1 vote
answered Apr 4, 2016 by Serieonisick (600 points)

This set of changes allows the appropriate error message to get returned.
It should translate the internal error to an external error here. So the question is what error should it get.
For more info read
commented Apr 6, 2016 by Lytal (370 points) 1 flag
It helps in keeping the code clean and helps debugging
+1 vote
answered Apr 7, 2016 by It_Fecat (310 points)

Logically, the select is evaluated before the actual insert operation is started.
If a column is not specified, the default value for the column is used. More details are here Insert (SQL) - Wikipedia, the free encyclopedia
commented Apr 9, 2016 by Cbv6805 (1,270 points)
Here is some reference
0 votes
answered May 27, 2016 by started (150 points)
I have overcome this problem by changing the device screen size
Please check this answer for a deeper explanation PHP: mysql_insert_id - Manual

Related questions

What is Geekub?

Q&A site for professional and enthusiast programmers, software developers and other technical users. With your help, we hope to work together to build a library of detailed answers to just about any question that is related to programming!