Jump to content

Duplicate entry '0' for key 1


jasraj

Recommended Posts

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

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')";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.