• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Handle error for duplicate entries - PHP/MySQL

phpmysqlerror-handlingtry-catch


PHP Snippet 1:

catch (PDOException $e) {

  if(str_contains($e, '1062 Duplicate entry')) {
      header("Location: login.php");

  }
      die("Error inserting user details into database: " .  $e->getMessage());

}

Related Snippets

Generate random username based on full name php

"cannot list resources" error from WooCommerce REST API

Additional price based on cart item count in WooCommerce

Cache clear probem in Larave

MySQL - Connection failed: No route to host

How to reset Laravel AuthManager/guards in between API calls in tests?

Stop caching for PHP 5.5.3 in MAMP

yii2 and mssql insert varbinary into model

Xdebug can't connect back to Docker host

How to convert time from one timezone to another in PHP

Last order would be re-order in wooCommerce. How is it possible?

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Wordpress 'post_type_link' hides permalink

Unable to uninstall brew php from homebrew

I want a way to give path to my files which are outside of public folder in laravel

About Contact Privacy policy Terms and conditions