MYSQL: Work with special characters

While programming with php, normally we works with mysql. And in mysql we insert, update, delete, fetch or compare string data.

But there are some special characters in a string which causes formatting level problems, values level problems and concatenation level problems while working with mysql.

And these special characters are: \x00 , \n , \r , \ , ‘ , ” , \x1a

For Example:
Our string is: Today is my friend’s birthday.

Here we want to insert this string in “description” field of “comments” table and compare it in select query.

So now we have to write queries using mysql_real_escape_string() to not cause any formatting, values or concatenation level problems and prevent database attack.

$query = "insert into comments (description) values ('" . mysql_real_escape_string("Today is my friend's birthday.") . "')";
$query = "select * from comments where description='" . mysql_real_escape_string("Today is my friend's birthday.") . "'";

Hope this will help you.

Extract files and directories from ZIP file in php

Some, Control Panel has no facility to extract files from the ZIP file. So that following script is useful to extract or unzip the zip file using php code.

Here, we have to provide the path from where zip file will be taking for extracting purpose and also provide the path where to put extracted files and directories (data).

See the Following script.

$zipObj = new ZipArchive();    // create zip object
$files = $zipObj->open(‘unzip/’); // Open Zip Archive
if ($files == TRUE)
	$zipObj->extractTo(‘extracted/’); // Unzip or Extract Zip file to given Directory.
Posted in PHP. 1 Comment »

How to remove an element from php array?

Before few days we have a requirement to remove an element from php array.

To fulfill our requirement we have used php functions.

There are three functions which can be useful to delete an element from php array.

“array_shift(array)” removes first element from an array.

“array_pop(array)” removes last element from an array.

“array_splice(array,start,length,array)” removes selected elements from an array and replaces it with new elements.

Follow the under given example to check it practically.

$array = array("first", "second", "third", "fourth", "fifth", "sixth");
array_splice($array, 0, 2);

Hope this will help you.

Posted in PHP. 1 Comment »

How to Solve IE9 Problem of Opening link in New Tab/Window

Whenever i was trying to open any link in new window/tab, I was getting a blank idle tab. I was facing this problem for last few months but finally got solution which i wanted to share with you guys. I’ve tried these following solutions but none was able to solve it.

I’ve tried:

  • Tried using IE9 with “no add-ons” mode
  • Rolled back to ie8 & then re-install IE9 again
  • Reset default settings from Advanced Internet Options
  • Deleted temporary Internet files, cookies, history… etc.
  • Used “Microsoft fix it”
  • & also tried “cmd” file from Microsoft that solves such problems “ie8-rereg.32on64.


Follow these methods:

Method 1:
Step 1: Boot into safe mode with networking and see if the issue persists.

See Advanced start-up options (including safe mode) for instructions on booting into safe mode with networking.

Note: Wireless connection may not work in safe mode with networking. I’d recommend you to use the wired internet connection in safe mode with networking.

Step 2: If the issue does not occur in safe mode, boot your system in a clean boot state (in normal mode) to troubleshoot the issue.

See How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

Note: After troubleshooting, ensure to set the computer to start as usual as mentioned in Step 7 in the above KB article.

Method 2:
Access the following link and refer to OnyXxL’s response posted on Wednesday, November 11, 2009 to fix the issue:

How To Insert the Tween Shape In Flash?

“In the timeline window, select any frame from 2-24 with left-click. In the properties window you can now see an option to tween which is currently set to none and from choose Shape from the tween drop down selector.Now insert another KeyFrame at frame 26. Left Click any frame from 27-49 & then select the Shape Tween from the Properties window.

Be sure that you follow the instructions up to this point exaclty is you have a dotted line, rather than a solid line in your Timeline window.”

How to add New field in Virtuemart 2.0?

If you need an additional field for your own business requirement, you can do that by changing data model as well as some php code.
To add new field for product you have to make changes in php code of 3 or more separate files in the previous Virtuemart joomla 1.5 but in virtuemart 2.0 and joomla 1.7 version you only have to make change in only one file to add field.

Admin interface

To add field in virtuemart admin side, first you have to create field in your product table into database then you need to add field for product in virtuemart.
Follow this path from your site root
File Name: product_edit_information.php for product
Add this type of code wherever you want to put new field.

<td width="21%" >[Your_Field_Name] </td>
<td >
<input type="text" class="inputbox" name="Your_Field_Name" value="<?php echo $this->product-> Your_Field_Name; ?>" size="32" maxlength="64" />

I hope this will help you.

Posted in Joomla. 3 Comments »

How to enable/disable the module in magento?

Some times magento new comers have no idea for “How to enable/disable the module in magento?”

So here is the guide for that.

The module/extension which we install or create in magento can be enable/disable from admin side.

Now to enable/disable the magento module, login to your magento admin.

Go to System -> Configuration from header menu.

Then click on “Advanced” option of “Advanced” tab from left column.

Here you can see the list of all installed or created magento modules/extensions. And you can enable/disable them by selecting appropriate value from combo.

Hope this will help you.

Posted in Magento. 1 Comment »