jasraj Posted August 14, 2009 Share Posted August 14, 2009 hey, i'm trying to gather reports for my website, but i keep getting the following error, not sure why. Duplicate entry '0' for key 1 <?php // find browser if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') ) { if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') ) { $browser = 'Netscape (Gecko/Netscape)'; } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') ) { $browser = 'Mozilla Firefox (Gecko/Firefox)'; } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') ) { $browser = 'Google Chrome (Gecko/Chrome)'; } else { $browser = 'Mozilla (Gecko/Mozilla)'; } } else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) { if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') ) { $browser = 'Opera (MSIE/Opera/Compatible)'; } else { $browser = 'Internet Explorer (MSIE/Compatible)'; } } else { $browser = 'Others browsers'; } // find IP $intpro = $_SERVER[REMOTE_ADDR]; // get page name $page = str_replace("/~gj719/gigbookers/", "", $_SERVER[php_SELF]); // get user ID $loginid = $_SESSION['userid']; $string = "INSERT INTO logreport (log_id, gblogin_id, page, browser, datetime, ipaddress) VALUES ('', '$loginid', '$gblogin_id', '$browser', NOW(), '$ipad')"; $result = mysql_query( $string ) or die ( mysql_error() ); ?> Link to comment https://forums.phpfreaks.com/topic/170271-duplicate-entry-0-for-key-1/ Share on other sites More sharing options...
wildteen88 Posted August 14, 2009 Share Posted August 14, 2009 Im guessing log_id is an auto_increment key? If its don't include it in your query. $string = "INSERT INTO logreport (gblogin_id, page, browser, datetime, ipaddress) VALUES ('$loginid', '$gblogin_id', '$browser', NOW(), '$ipad')"; Link to comment https://forums.phpfreaks.com/topic/170271-duplicate-entry-0-for-key-1/#findComment-898183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.