Archive for the ‘php’ Category

A quick introduction of .htaccess with examples

Posted: 27th October 2018 by azinkey in php
Tags: ,

What is .htaccess? The .htaccess file is a configuration file that affects how a webserver responds to various requests. Why is it called .htaccess? (Hyper Text + Access) These files were first used to control user access on a per-directory basis. Where is the .htaccess file? every folder (directory) on your server could have one […]

  First you need to check whether the user or data is exits or not. then 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 $query […]

Suppose you have approx 1000 image files for download, then here is a command to download all them. Create a text file named it urls.txt enter all urls each url in a new line type WGET -i urls.txt in your terminal WGET -i urls.txt

CakePHP in a subdirectory using nginx

Posted: 10th August 2017 by admin in php
Tags: , , , , ,

CakePHP in a subdirectory using nginx cakephp subdirectory nginx I was facing many issues in setup cakephp3 in subfolder on nginx server. I was doing changes in new server config while we have to do that in existing server config(well that work for me :) )     So I just add following in default […]

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 += […]

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 […]

Push notification IOS

Posted: 13th February 2017 by admin in Iphone, php
Tags: , , , , , ,

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 […]

configure ejabberd xmpp ubuntu server part 2 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 add the following line in […]

Configure ejabberd xmpp ubuntu server     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 mysql. Step 1: First Update Ubuntu Server  with […]

export database table by php

Posted: 30th December 2015 by admin in mysql, php
Tags: , , ,

export database table php Sometime there is need to export database table by php code. There is a very simple approach to do this.     /*******EDIT LINES 3-8*******/ $DB_Server = “localhost”; //MySQL Server $DB_Username = “”; //MySQL Username $DB_Password = “”; //MySQL Password $DB_DBName = “”; //MySQL Database Name $DB_TBLName = “tablename”; //MySQL Table […]