Posts

Multiple Like clauses with where condition in CodeIgniter

Many time we stuck in some situation if we want add multiple like queries with where condition, So for this, you should use Grouping where clause, see below example: $this->db->where('status','1'); $this -> db -> group_start (); //group start $this->db->like('contact_name',$filter_key); $this->db->or_like('contact_email',$filter_key); $this->db->or_like('contact_number',$filter_key); $this->db->or_like('company_name',$filter_key); $this->db->group_end(); //group end $query = $this->db->get('contacts');

Solved - MySQL server has gone away in wammp

Hi Guys, MySQL server has gone away error occurs when you passed max allowed packets may be your query will be crossed max number of line.   Follow below steps to fix:  Go to MySQL installed folder C:\wamp64\bin\mysql\mysql5.7.23 Open my.ini and find max_allowed_packet   Increase  max_allowed_packet  variable Restart wammp or MySQL server 

Solved - How To Disable "Connect Jetpack to activate WooCommerce Services"

Hello Guys, You can fix "Connect Jetpack to activate WooCommerce Services" notification message from wordpress admin area, just copy and paste below code into you theme's functions.php. add_filter( "woocommerce_helper_suppress_admin_notices","'__return_true );

Fixed: Sorry, this file type is not permitted for security reasons

The main reason behind this error in WordPress is more straightforward than it might seem. We can not know it, but WordPress has restrictions on the some types of files we can upload. The error "Sorry, this file type is not permitted for security reasons."  appears when we try to upload a prohibited file type like .svg, .svgz, .docs etc. We can fix this issue using following methods: 1. Modify file types using a Plugin: There are several plugins capable of enabling you to upload prohibited file types, such as File Manager and Enhanced Media Library . 2. Use the upload_mimes filter by editing theme's functions.php file and paste below code: function av_custom_mime_types( $mimes ) { // Add new new allowed mime types $mimes['doc'] = 'application/msword'; $mimes['svg'] = 'image/svg+xml'; $mimes['svgz'] = 'image/svg+xml'; // You can remove any particular mime type (Optional) unset( $mimes['exe'] ); ...

Show loader image and disable page/section while waiting for ajax request

Show loader image and disable page or div section while waiting for ajax request. Use below example code: HTML <!-- Image loader --> <div id="loader" class="ajax_loader" style="display: none;">   <img src="images/ajax-loader.gif" width="32px" height="32px" /> </div> JS $.ajax({ type: 'POST', url: 'URL', dataType: 'json', data: user, beforeSend: function(){ $("#loader").show(); },success:function(response){ //Put your logic after success }, complete:function(data){ $("#loader").hide(); } }); Note: Include jquery.js before use above js CSS <style> .ajax_loader{ position:absolute; width:100%; height:100%; left:0; top:0; background:rgba(0,0,0,.5);} .ajax_loader img{ position:absolute; left:50%; top:50%;} </style>

Fixed: this is incompatible with sql_mode=only_full_group_by in MySQL

When you execute a query having GROUP BY against a database in MySQL you could have encountered the error "this is incompatible with sql_mode=only_full_group_by” in MySQL". Below are the steps to fix the issue. 1. Edit MySQL configuration sudo nano /etc/mysql/conf.d/mysql.cnf 2. Append below code and save and exit [mysqld] sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 3. Restart MySQL server sudo service mysql restart

Nested promises in node.js

In node.js promises give you return statements and error throwing, which you lose with continuation passing style. Example: var createJob =  function(jobData){   if(!jobData){     console.log('Job data should not be empty!');   }else{ let jobData = []; let location = "San Francisco, CA California, US"; let locationArr = location.split(','); let stateName = locationArr[1].trim(); let country = locationArr[2].trim(); getCountryID(country).then(function(countryID){   jobData['countryID'] = (countryID>0 ? countryID : null);   getStateID(stateName,countryID).then( function (stateID){ jobData['stateID'] = (stateID>0 ? stateID : null); return jobData;   }); }, function(error) {   console.log(error); });   } } function getCountryID(countryName){   var promise = new Promise(function(resolve, reject) { //You can write here your logic resolve( 25 ); //countryID   });   return pr...