A quick introduction of .htaccess with examples

What is .htaccess? The .htaccess file is a configuration file that affects how a web server responds to various requests. .htaccess files provide a way to make configuration changes on a per-directory basis. Why is it called .htaccess? (Hyper Text + Access) These files were first used to control user access on a per-directory

Read More

Codeigniter insert if not exist and update if not

Codeigniter insert if not exist and update if not First you need to check whether the user or data is exits or not. after that you can perform the update and insert operation. $this->db->where('user_id',$id); $q = $this->db->get('profile'); if ( $q->num_rows() > 0 ) { $this->db->where('user_id',$id); $this->db->update('profile',$data); } else { $this->db->set('user_id', $id); $this->db->insert('profile',$data); } There is one more way by using mysql query

Read More

codility brackets opening and closing solution

Codility brackets opening closing. codility brackets opening closing. codility you are given a string s consisting of n brackets opening problem solution. function isBalanced($str){ $count = 0; $ocount = 0; $ccount = 0; $length = strlen($str); for($i = 0; $i < $length; $i++){ if($str[$i] == '(') $ocount += 1; else if($str[$i] == ')') $ccount += 1; if($ccount == $ocount){ $count = $ocount; }else{ $count = $ccount; } } return

Read More

Push notification Android Php

Hey, Today we learn how to send push notification for android in php. First create a class with following code <?php class Pusher{ const GOOGLE_GCM_URL = 'https://android.googleapis.com/gcm/send'; private $apiKey; private $proxy; private $output; public function __construct($apiKey, $proxy = null) { $this->apiKey = 'your_key'; $this->proxy = $proxy; } /** * @param string|array $regIds * @param string $data * @throws Exception */ public function notify($regIds, $data) { // pr($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,

Read More

Push notification IOS

Push notification IOS <?php // authentication $host = "localhost"; $user = "user"; $pass = "pass"; $dbname = "DB"; // create connection with database $con = mysql_connect($host, $user, $pass); // check whether database connection is successful if (!$con) { // if connection not successful then stop the script and show the error die('Could not connect to database: ' . mysql_error()); } else { // if

Read More

Configure ejabberd xmpp on ubuntu server part-2

configure ejabberd xmpp ubuntu server part 2 configure ejabberd xmpp ubuntu server part 1 In First Tutorial we have configure ejabberd XMPP with default menisa database . now in this tutorial i will explain how to configure ejabberd with MySql .     Step 1 :  Open etc/ejabberd/ejabberd.cfg file and comment following line : {auth_method, internal}. and

Read More

Configure ejabberd xmpp on ubuntu server Part-1

Configure ejabberd xmpp ubuntu server Configure ejabberd xmpp ubuntu server part 2     After facing so many issues and investing so many hours I write below steps for configure ejabberd. In first tourial we learn how to configure ejabbere on AWS EC 2 Ubuntu server. In second tutorial we will configure it with

Read More