Thursday, 8 January 2015

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 2269548 for key PRIMARY

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 2269548 for key PRIMARY

Following are few reasons with solutions:

Reason 1:
ID is auto-increment and primary key. id is auto filed when an record is insert.
When we try to insert record with same id which is already exist in table, then such type of error comes.
SOLUTION:
So, write SQL in following ways.
INSERT INTO users (name) VALUES ('name1'); //skip the id field which is auto-increment


Reason 2:
When table is used to frequent insertion of records, like we are storing db logs for each action. Sometimes, it have thousand of thousands records, and field(like id) limit cross the limit. SOLUTION: Increase the limit of id field.
ALTER TABLE `users` CHANGE `id` `id` BIGINT(10) UNSIGNED NOT NULL AUTO_INCREMENT; 
Reason 3:
When table is used to frequent insertion of records, like we are storing db logs for each action.Sometimes, it have thousand of thousands records, and table goes to overhead.
SOLUTION: Execute following query
OPTIMIZE TABLE `users`

Wednesday, 7 January 2015

Facebook Comments Disable Comment using Yahoo, AOL or Hotmail

Facebook Comments  Integration and Disable Comment using Yahoo, AOL or Hotmail


To integrate Facebook Comments without Yahoo, AOL Hotmail, Get an Facebook Apps ID
  • Login in Facebook.com
  • Go to https://developers.facebook.com
  • Create an Apps in facebook
  • Get App ID
  • Append below meta tags in header & update your FB APP ID

Use following code snippet to use
<div id="fb-root">
</div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;appId=508427595967225&amp;version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-colorscheme="light" data-href="http://www.web-technology-experts-notes.in/2015/01/facebook-comments-disable-comment-using.html" data-numposts="5" data-width="570">
</div>


See Example Below




You can manage following Options in Facebook Comment Box.
  • data-colorscheme: Color scheme used by the plugin. Can be "light" or "dark".
  • data-numposts: Total no of comments wants to display at the time of page load.
  • width: Total widths of facebook comments box