I just setup a LAMP server in an Amazon Linux instance. Everything is working fine and all my connections with my database are working great.
But I'm having a problem that I just can't figure out. I am working on an exam system and I want to give a random id to each student that is going to take it. I don't need any info about the students so I don't have any relevant fields that I could use as unique identifiers.
$sql = "INSERT INTO pinion_evalua (id_eval,id_escuela,anio) VALUES (".$id_eval.",".$id_escuela.",".$id_grupo.")";
Error: INSERT INTO pinion_evalua(id_eval,id_escuela,anio) VALUES (4612160288,1,2)
Duplicate entry '2147483647' for key 'id_eval'
You have many problems in those few lines of code:
3); delete pinion_evalua where (1 = 1. The proper solution would be to use prepared statements as documented in the PHP manual.