Mar 02

Dynamic bind_param for mysqli update query in PHP

If you need to dynamically bind params to an UPDATE query when you are using mysqli statement you will face some troubles. But few lines far you are going to find the right solution for you

$query = '';
 $flag = false;
 $bindParam = '';
 $refArray = array();
 $refArray[] = &$bindParam; //set the 0 field
//Manage int value and first variable
 if (isset($our_integer_value)) {
 $query.='id_our_field = ?';
 $flag = TRUE;
 $refArray[0] = &$bindParam;
 $refArray[] = &$our_integer_value;
//Manage date
 if (isset($date)) {
 if ($flag)
 $query.='date = FROM_UNIXTIME(?)';
 $flag = TRUE;
 $refArray[0] = &$bindParam;
 $refArray[] = &$date;
//Manage string
 if (isset($date_info)) {
 if ($flag)
 $query.='date_info = ?';
 $flag = TRUE;
 $refArray[0] = &$bindParam;
 $refArray[] = &$date_info;
 $refArray[0] = &$bindParam;
 $refArray[] = &$id_element;
$conne = $this->conn;//you could use you connection element
 $stmt = mysqli_stmt_init($conne);
 $stmt->prepare("UPDATE element SET " . $query . " WHERE id_element = ? ");
 call_user_func_array(array($stmt, 'bind_param'), $refArray);
if ($stmt->execute()) {
 return true;
 } else {
return $stmt->error;


Feb 29

Fix PHP blank page and manage errors without server access

If  you have a blank page and you don’t any access to web server log you can use these few lines of code before the your PHP code causing the crash.

// Display Errors 
ini_set('display_errors', 'On');
ini_set('html_errors', 0);
// Error Reporting 
// Shutdown Handler 
function ShutdownHandler() {
 if (@is_array($error = @error_get_last())) {
 return(@call_user_func_array('ErrorHandler', $error));

// Error Handler 
function ErrorHandler($type, $message, $file, $line) {
 $_ERRORS = Array(0x0001 => 'E_ERROR', 
 0x0002 => 'E_WARNING', 
 0x0004 => 'E_PARSE', 
 0x0008 => 'E_NOTICE', 
 0x0010 => 'E_CORE_ERROR', 
 0x0020 => 'E_CORE_WARNING', 
 0x0040 => 'E_COMPILE_ERROR', 
 0x0080 => 'E_COMPILE_WARNING', 
 0x0100 => 'E_USER_ERROR', 
 0x0200 => 'E_USER_WARNING', 
 0x0400 => 'E_USER_NOTICE', 
 0x0800 => 'E_STRICT', 
 0x1000 => 'E_RECOVERABLE_ERROR', 
 0x2000 => 'E_DEPRECATED', 
 0x4000 => 'E_USER_DEPRECATED');
 if (!@is_string($name = @array_search($type, @array_flip($_ERRORS)))) {
 $name = 'E_UNKNOWN';

 return(print(@sprintf("%s Error in file \xBB%s\xAB at line %d: %s\n", $name, @basename($file), $line, $message)));

$old_error_handler = set_error_handler("ErrorHandler"); 
// other php code


Mar 25

Cannot install language in Prestashop on localhost

Installing Prestashop on your PC using AMP platform like XAMPP can become a trouble, first of all we are using Windows OS. If you have the following error:  Cannot install language “English (English)” or any others languages ( we test it also for Italiano ) the solution is not so easy to bring out. Continue reading “Cannot install language in Prestashop on localhost” »

Jul 27

Send var_dump result to a string variable with PHP

Maybe you need to capture var_dump result in a variable to use it like a string in you context. You don’t want to output result but just have it in your hand.

Continue reading “Send var_dump result to a string variable with PHP” »

May 17

json_encode(): Invalid UTF-8 sequence in argument and SLIM

Yesterday i stumbled on this error : json_encode(): Invalid UTF-8 sequence in argument . Searching on the net doesn’t resolve the issue but as usual gives me some other point of view to find the solution.


I’m using Slim Framework and a Mysqli connection to retrieve data from a MySQL Database, then i want to output the result of the query encoded in JSON format. Continue reading “json_encode(): Invalid UTF-8 sequence in argument and SLIM” »

Apr 11

CVE-2014-0160 aka Heartbleed

During the last days a bug in OpenSSL was found, codename “Heartbleed”, but probably is better say “Carnage”.

First of all, how i know if i’m vulnerable? OpenSSL version  1.0.1 through 1.0.1f (inclusive) are vulnerable.

Generally, you’re affected if you run some server that you generated an SSL key for at some point. Most end-users are not (directly) affected; indeed if they use update browers this is true, instead also an end-user could be affected according to openssl security bullettin. Continue reading “CVE-2014-0160 aka Heartbleed” »

Apr 11

Mobile Device Management

The goal of this article is to explain first of all the meaning and the funtionality of a MDM, after that try to understand, giving parameter if this is really what you need, because outhere there are a tons of opportunity, you have just pick the right one.

Mobile device management (MDM) providers continue to partner, develop and acquire mobile technologies to support a broader enterprise strategy, including the areas of security, enterprise file synchronization and sharing (EFSS), and application management. The basic technology components of MDM are similar among MDM vendors, but the user experience, analytics and broader offerings are differentiated.
The mobilespecific MDM companies are still providing leading vision and technology in MDM software, but the bigger software and security companies are catching up. Continue reading “Mobile Device Management” »

Apr 11

Cloud Computing and Security

We have to start our travel in Cloud Computing defining it, we can find a useful partner in the NIST (National Istitute of Standards and Technology).

NIST define Cloud computing as a model for enabling ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction. This cloud model is composed of five essential characteristics, three service models, and four deployment models. Continue reading “Cloud Computing and Security” »

Mar 09

Order_status_id = 0 in OpenCart

If you look deep inside OpenCart Db you can find order_status table. In it you find these fields:

  • order_status_id : used by OpenCart in order table to indicate the status of the order, like “Pending”, “Complete”, “Canceled”
  • language_id : if you have only English installed you have “1” as solely value
  • name : the translation string Continue reading “Order_status_id = 0 in OpenCart” »

Feb 18

Security header is not valid – Opencart

If you get in trouble with paypal configuration( Paypal Express Checkout) in an Open Cart e-commerce website; the solution is outside Open Cart.

It’s not a mistype configuration of API username, password and signature but just try to renew your paypal credential or fix it at paypal account website

Older posts «