Search

Bhavesh M Khanpara

PHp Developer with 5+ Years Experience

Set null to empty in Webservices responce


Note : when API return responce  convert null value to empty value for avoid mobile app crashes

$json_params = array();
if (!empty($value[‘method’])) {
$params = $value[‘body’];
if (!empty($params)) {
foreach ($params as $key => $val) {
$params[$key] = addslashes_deep($val);
}
}
$obj->params = $params;
$result = $obj->$method();
//$sql = “INSERT INTO `webservices_log` (`VApiName`, `vRequestMethod`, `tRequestParams`, `tResponseParams`) VALUES (‘” . $value[‘method’] . “‘ , ‘POST’, ‘” . $post_data_string . “‘, ‘” . json_encode($result) . “‘)”;
//$sqlRes = mysql_query($sql);
} else {
/**
* Redirect to index page if method did not found in request service call.
*/
$result[‘result’] = 1;
$result[‘service_data’] = array();
$result[‘message’] = “Service Method was not specified!!!”;
if (isset($_POST[‘show_array’]) && $_POST[‘show_array’] == ‘on’) {
print_r($result);
} else {
$json_result = json_encode($result);
echo trim($json_result);
}
}

/**
* Set Display of service response either in array or json format.
*/
if ($_POST[‘show_array’] == ‘on’) {
array_walk_recursive($result, “nullToEmpty”);
$result = stripslashes_deep($result);
print_r($result);
} else {
array_walk_recursive($result, “nullToEmpty”);
$result = stripslashes_deep($result);
$json_result = json_encode($result);
echo trim($json_result);
}

/**
* Conver Null to empty
*
* @param int $value
* @return string
*/
function nullToEmpty(&$item, &$key) {
//echo $key;
if (is_null($item)) {
$item = “”;
} else
if (is_string($item)) {
//$item= utf8_decode($item);
}
}

function stripslashes_deep($value) {
if (is_array($value) || is_object($value)) {
$value = array_map(“stripslashes_deep”, (array) $value);
} else {

$value = stripslashes($value);
}
return $value;
}

function addslashes_deep($value) {
if (is_array($value) || is_object($value)) {
$value = array_map(“addslashes_deep”, (array) $value);
} else {
$value = addslashes($value);
}
return $value;
}

?>

Advertisements

fetch data from google drive sheet


<!DOCTYPE html>
<head>
<meta charset=”utf-8″>
<title>Widget</title>
<link href=”style.css” rel=”stylesheet”>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script&gt;
<script>
$(document).ready(function(){
var ajaxFn = function () {
$.ajax({url: “https://spreadsheets.google.com/feeds/list/YOUR KEY/od6/public/values?alt=json”, success: function(result){
var a = JSON.parse(JSON.stringify(result));
var b= a.feed.entry
var temp_str=”;
var temp={};
b.forEach(function(item){
if(item.gsx$_cpzh4){
//this is for 3 coloum data
temp[item.gsx$_cn6ca.$t]=item.gsx$_cokwr.$t+”_”+item.gsx$_cpzh4.$t+”_”+item.gsx$_cre1l.$t;
}else{
if((item.gsx$_cn6ca)!=undefined && (item.gsx$_cokwr)!=undefined){
temp[item.gsx$_cn6ca.$t]=item.gsx$_cokwr.$t;
}
}
});
$(‘#code_us_value’).text(temp[‘% US’]*100);
$(‘#total_idea_val’).text(temp[‘Total Requests’]);
}});
}
//OR use BELOW line to wait 10 secs before first call
setInterval(ajaxFn, 1000);
});
</script>
</head>
<body>
<div class=”container”>
<div class=”widget-wrap”>
<p class=”bignumber total_idea”><span id=”total_idea_val”>333,221</span></p>
<p>Total requests for stickers</p>
<p class=”split”><span class=”us”>US: <span id=”us code_us_value”>83</span>%</span><span class=”nonus”>Non-US: 17%</span></p>
<img src=”img/x.png” alt=”” class=”img-multiply”>
<p>Cost to print & ship a sticker</p>
<p class=”split”><span class=”us”>US: $1.05</span><span class=”nonus”>EU: $1.73</span></p>
<img src=”img/eq.png” alt=””>
<p class=”bignumber”>$376,125</p>
<p>Needed to print & ship stickers</p>
<input type=”image” src=”img/donate.gif” class=”btn-donate” />
<p>or <span class=”buyone”>buy one</span> to send some in our store</p>
</div>
</div>
</body>
</html>

What is difference between MYISAM and InnoDB?


I am writing this article to all those PHP follower to understand the difference between MYISAM and INNODB.

MYISAM:
1. MYISAM supports Table-level Locking
2. MyISAM designed for need of speed
3. MyISAM does not support foreign keys hence we call MySQL with MYISAM is DBMS
4. MyISAM stores its tables, data and indexes in diskspace using separate three different files. (tablename.FRM, tablename.MYD, tablename.MYI)
5. MYISAM not supports transaction. You cannot commit and rollback with MYISAM. Once you issue a command it’s done.

INNODB:
1. InnoDB supports Row-level Locking
2. InnoDB designed for maximum performance when processing high volume of data
3. InnoDB support foreign keys hence we call MySQL with InnoDB is RDBMS
4. InnoDB stores its tables and indexes in a tablespace
5. InnoDB supports transaction. You can commit and rollback with InnoDB

CCAvenue Payment Gateway integration in PHP


HOWDY

CCAvenue is the largest Payment Gateway in India today and currently powers more than 85% of the e-commerce merchants in the country.
To integrate with this in your website, you need ccavenue merchant account, to create merchant visit this link.

Follow the steps to integrate ccavenue in your website:-

1. There are three important files you have to write into your website

First file is libfuncs.php3 – see the code below
This file has some functions which is for checkout and redirect pages, we must include this page in checkout and redirect pages
———————library functions starts here——————–
<?php
function getchecksum($MerchantId,$Amount,$OrderId ,$URL,$WorkingKey)
{
            $str =”$MerchantId|$OrderId|$Amount|$URL|$WorkingKey”;
            $adler = 1;
            $adler = adler32($adler,$str);
            return $adler;
}
function verifychecksum($MerchantId,$OrderId,$Amount,$AuthDesc,$CheckSum,$WorkingKey)
{
            $str = “$MerchantId|$OrderId|$Amount|$AuthDesc|$WorkingKey”;
            $adler = 1;
            $adler = adler32($adler,$str);
            if($adler == $CheckSum)
                        return “true” ;
            else
                        return “false” ;
}
function…

View original post 1,508 more words

Chosen – A Sleek jQuery plug-in for auto-search, auto-suggestions, multi-select within drop down lists for desktop browsers


NABEEL SHAHID's Blogs

Chosen – A Sleek jQuery plug-in for auto-search, auto-suggestions, multi-select within drop down lists for desktop browsers #Chosen

Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly.

One of the best plug-ins available for drop down lists with searching facility.

Chosen is a library for making long, unwieldy select boxes more user friendly.

  • jQuery support: 1.4+
  • Prototype support: 1.7+

For documentation, usage, and examples, see: http://harvesthq.github.io/chosen/

For downloads, see: https://github.com/harvesthq/chosen/releases/

Brower Installation

Chosen does not currently support command-line bower install chosen installation. This is because the repo does not contain the compiled sources, and bower does not currently support adding a post-install/build step.

However, you can specify that you’d like to use the release ZIP, which includes the compiled and minified sources.

Either install from the command line with

$ bower install https://github.com/harvesthq/chosen/releases/download/v1.3.0/chosen_v1.3.0.zip

or add Chosen to your own project’s bower.json file…

View original post 1,029 more words

Install Command of NetBeans IDE 8.0 on Ubuntu 13.10, 14.04


InVeRsEpLaNeT

NetBeans is a free and open source IDE (Integrated Development Environment) for developers. NetBeans allows users or developers to quickly build mobile and web applications using HTML, PHP, C and C++.

The latest stable release of NetBeans – IDE 8.0, has been released with following features:

  • Java 8 Code Analyzers
  • Java 8 Code Editors
  • Support for Java SE 8, Java SE Embedded 8 and Java ME Embedded 8
  • Enhanced Maven Support
  • Enhanced Java EE 7 Support with PrimeFaces
  • New Tools for HTML5 and AngularJS
  • Improved PHP and C/C++ Support

Step 1: Install Java SE Development Kit (JDK) 8

– NetBeans IDE requires Oracle JDK installed first. Run following commands to install JDK

sudo apt-get purge openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Note: you will be prompted to accept…

View original post 173 more words

AngularJS + REST Made Simple: Connecting AngularJS to a Backend with REST & JSON


Resources to learn python


Retrieval of duplicate values from the table


Software Testing

select * from Employee (nolock) where Empid in
(
SELECT DISTINCT Empid FROM Employee (nolock) WHERE Empid IN
(‘8807′,’32835′,’49962′,’486734′,’39871′,’17753′,’18726’
—all employee id of the table)
GROUP BY Empid
HAVING COUNT(Empid) >1
)

View original post

Blog at WordPress.com.

Up ↑