0

Attendance Table:

  1. AttendID (AUTO_INCREMENT) (Primary Key)
  2. StudID
  3. ClassID
  4. attended

This SQL Insert is inserting records to my Attendance Table:

$query = mysql_query("insert into attend (StudID, ClassID, attended) values ('$data', '$data1', 1)", $connection);

But When I make the [StudID] and [ClassID] columns as Foreign Keys each one to a different table, The Insert won't insert records to my Attendance Table and there is no error showing in my code.

Help Please :(

Noor H
  • 13
  • 1
  • do you know for sure that there is a record in the student and class tables that corresponds with your foreign keys? – Jeremy C. May 18 '15 at 11:56
  • 1
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and consider using PDO, [it's not as hard as you think](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 18 '15 at 11:57
  • Add error reporting to the top of your file(s) right after your opening ` – Jay Blanchard May 18 '15 at 11:57

0 Answers0