Sunday, October 19, 2014

Don't be unfair with serialize() !

Hello my friends ,

Today I want to talk about Serialization .

Most of us as developers doesn't interested in serialization concept within developing process , we can say that serialization is the process of translating data structures or object state into a format that can be stored.

Relational database (
RD) model and serialization are very friends , RD doesn't allow multi-valued cell , and serialization handle that , you can store multidimensional array on one cell on your table as a string using serialization.

If you ignore relationships on your database model and only depend on serialized data so you are escaping from 
relational database concept,and if you ignore serialization generally  your result may be huge and complex model and that is not right.

The standard PHP function serialize is just a format to express such a thing, it serializes a data structure into a string representation that's unique to PHP and can be reversed into a PHP object using unserialize. There are many other formats though, like JSON or XML.

many built-in PHP objects cannot be serialized. However, those with this ability either implement the Serializable interface or the magic __sleep() and __wakeup() methods. If an internal class does not fulfill any of those requirements, it cannot reliably be serialized.

Example :
<?php// $session_data contains a multi-dimensional array with session
// information for the current user.  We use serialize() to store
// it in a database at the end of the request.
$conn odbc_connect("webdb""php""chicken");$stmt odbc_prepare($conn,
"UPDATE sessions SET data = ? WHERE id = ?");$sqldata = array (serialize($session_data), $_SERVER['PHP_AUTH_USER']);
if (!
odbc_execute($stmt$sqldata)) {
$stmt odbc_prepare($conn,
"INSERT INTO sessions (id, data) VALUES(?, ?)");
    if (!
odbc_execute($stmt$sqldata)) {
/* Something went wrong.. */

Sunday, October 12, 2014

Change database URLs may damage you site !

Every PHP developer especially  Wordpress developer facing this fact 'We changed our domain name !', the client(site owners) never mind what are the effects that will happen when the site Url change,only developers have to do adjustments to fix all bad effects.
Wordpress as CMD (Content Management System) uses serialized arrays to save options related to themes and other settings.

Every serialized array depend on content (String) and length (Integer) , when you change the URL by find and replace method manually you will change the string but not the length so you will put PHP in aproblem when it will refuse this serialized array and then you will not get the result.

This was my email to my manager , i told him what's happened with me when i was changed the database url manually from the Ubuntu terminal (Shell Commands)

When I was trying to publish the new site from this URL ( to ( ,there was a need to change the URLs on the database, so I used the find and replace tool manually .

The result was : a lot of widgets,menus and theme options were missing.

And after hard searching for this problem I found that : WordPress stores many options as "serialized data", which contains both the string content of things and their length. So when you modify the URL and the length changes, then the serialized data is no longer correct, and PHP rejects it.

So if you want to change database URLs safely you have to use tool like this.

Best Regardes ..

Hussam Hussien 

Sunday, September 28, 2014

Programming is symbols or a science

Hello ,
I'm very happy to post my first post to you , there is a very important issue i would like to talke about it ..

So let's start , developing in general depend on two basic skills concept and coding ,most of rich people have a loyalty to coding skill and this is due to tunnels on courses which are focus on "how to have a skill to develop by a specific programming language (i,e java , php  etc).

But concept skill has other lovers , people they are searching for concept  , they are searching for knowledge , idea and creativity,they are not only satisfied with specified programming language  tools they are look forward how it's working and how they can develop new tools.

Finally , if you want to learn programming you have to learn it as some symbols you can use to build an application , but you have to learn it  as a science , you can then have them together concept and codding skills .

Best regards.

Sunday, September 21, 2014

Welcome To My Blog

"Keep Calm And Welcome To My Blog " ,
Hello , my friends and every one i decided recently to publish this blog , in order to find a gate to reach people when we can get benefit from each other ..

"Not Only IT"
The main purpose of my blog is IT Issues , but i want to say that we can look aware with wide-ranging.