Q:

php script returning error 'Duplicate entry '0' for key 'PRIMARY' whereas the sql command works fine

The following query runs fine in phpmyadmin and rows get inserted but in php script its causing problems . Please suggest solution
INSERT INTO NamazTiming 
(`FajarAzan`,`FajarZamat`,`ZoharAzan`,`ZoharJamat`,`AsarAzan`,`AsarJamat`,`Maghrib`,`IshaAzan`,`IshaJamat`,`JumaAzan`,`JumaJamat`,`Taraweeh`,`FromDate`,`ToDate`,`MasjidID_FK`)
VALUES
('04:25:07',
'04:25:07',
'5:48:07',
'04:25:07',
'12:29:07',
'04:25:07',
'15:49:07',
'04:25:07',
'19:08:07',
'04:25:07',
'20:31:07',
'04:25:07',
'2014-06-11',
'2014-06-20',
'39')

Error given by script
'Duplicate entry '0' for key 'PRIMARY'

The following is in my php script 
    $result = mysql_query("INSERT INTO NamazTiming 
(`FajarAzan`,`FajarZamat`,`ZoharAzan`,`ZoharJamat`,`AsarAzan`,`AsarJamat`,`Maghrib`,`IshaAzan`,`IshaJamat`,`JumaAzan`,`JumaJamat`,`Taraweeh`,`FromDate`,`ToDate`,`MasjidID_FK`)
VALUES
('$FajarAzan',
'$FajarJamat',
'$ZoharAzan',
'$ZoharJamat',
'$AsarAzan',
'$AsarJamat',
'$Maghrib',
'$IshaAzan',
'$IshaJamat',
'$JumaAzan',
'$JumaJamat',
'$Taraweeh',
'$FromDate',
'$ToDate',
'$MasjidID')") or die(mysql_error());

A:

As the primary key does have the auto increment value, it looks like you may have restored data or the auto increment value has been reset. 
This query should resolve this:
SELECT max(NamazTimingID_PK)+1 FROM NamazTiming LIMIT 1;
ALTER TABLE NamazTiming AUTO_INCREMENT = <result>;

Replace  with the returned value from the select statement.

