Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.