Monday, 23 December 2013

Android Bootloop problem Fixed: The 'Jugaad' way

Leave a Comment
Having an Android phone arouses that natural inquisitiveness to play around with its firmware, to root the phone, install custom ROMs and do all sorts of crazy things with it. However, sometimes, you might end up messing up your beloved phone, and then start cursing yourself for all the foolishness you did. I was in a similar situation recently. With the craze for Kitkat spreading like a wild fire, I decided to install the latest Android 4.4 on my Samsung Galaxy S2. Be rest assured....this one time Samsung flagship device still holds strong when it comes to installing the latest firmwares. So, on the quest for Kitkat, I downloaded the CM 11 for GT-i9100, and with my phone already rooted, I took the Nandroid backup using the clockworkMod recovery. All set for yet another experiment on my phone (and has never disappointed me when it comes to flashing custom roms) I flashed the CM an error (Status 7), and the flashing failed. Determined to get Kitkat by hook or by crook, I did a factory reset of my phone...having at the back of my mind that I still have the complete system backup. Then I flashed the stock jelly bean  ROM, just to make sure that the current custom rom on my phone is not causing a problem while flashing a new rom. Again, I tried with Kitkat, but it still gave the same error!! Now, why did the error occur is altogether a different mystery, which I'm yet to figure out. The problem started, when I tried restoring my backup...the phone got stuck in Boot of the worst nightmares for android users!!

Now, generally, the boot loop problem gets fixed by removing the battery for some time and restarting the phone, or by wiping the cache and Dalvik cache repeatedly. However, it seemed that it wasn't my day, and everything I tried failed to boot my phone. And then I started doing something that almost everyone does at such situations...cursing myself...and more because I had done a factory reset of my phone. So, even though I knew that I can get back my phone by flashing the stock firmware, there was no chance, that I could get back my apps and data, which meant...the painful process of reinstalling everything from scratch. And what about all my messages...and all those levels I had completed in NFS, and what about my highest score in Temple am I gonna get all those things back??!! I tried googling a lot, but every forum said just one thing...flash the stock rom in case of boot loop problem, but damn!! wont get back your data.

And then suddenly, a thought occurred...a way around...a 'Jugaad' that we are so good at!! I had the nandroid backup with me...which meant I had the backup of my apps and data in it. The problem was with booting the phone right? There was still a chance that the apps and data had been restored from the backup. So, firstly, I did a factory reset of my phone...just to wipe out everything that was in there. Then, I restored the nandroid backup (as expected, the phone got stuck in boot loop again). And then came the master stroke...I flashed it with the stock firmware I had with me. And then came the prayers....God...please give me my phone back....please...please!!

It went past the Samsung heart racing like hell now....'Upgrading Android'....'Initializing the apps'....and Bingo!! Everything was in place...all my apps, all my contacts, messages...everything!! The only problem now was that my phone was not rooted as it was earlier, and it was again filled with all sorts of scrap inbuilt apps from Samsung, which I had previously removed. But that was welcome, as it was just a matter of few minutes and I could root my phone and purge it of those silly apps. The great thing was, that I got back my phone...and I had started loving it all the more now!!

So, for all those who had given up after the boot loop problem....there is always a way....that's the beauty of Android! The only thing that you should have at your disposal is a backup of your phone.

So, here's the jugaad in two simple steps:
Step 1. Restore the nandroid backup(This is where the boot loop problem started for me)
Step 2. Flash the stock firmware over the nandroid backup

You'll have your phone 'almost' as it was earlier, with all your apps and data.

Have Queries?? Post it on our Discussion Forum Compild


Monday, 9 September 2013

Read an Excel file using PHP

Reading an excel file using some server-side scripting language is something that should be in the ammo of any developer. Now, Excel is something which I have always stayed away from...blame it on the insipid UI, or lack of various other features which databases like Oracle, MySql etc provide. However, one cannot deny the fact that Excel is rampantly used to maintain records, and at some point or other, you may have to use excel as an input to your code.

I had faced such a situation recently, and after some googling, I managed to find a way to read the excel sheet and insert the corresponding entries to a MySql database. So, this post of mine will help you in reading an excel sheet using PHP. Once it is read and you have the values of the entries with you, its up to you as to what you like to do with it. In my case, I simply inserted those values in a MySql database.

Have queries?? Get them resolved...

What you need to get started:

Download the above two packages. Extract both the packages. Now, in the PHPExcelReader package, find the Copy this file, and paste it to Spreadsheet\Excel\Reader folder in the SpreadsheetExcelWriter package. It does not have the Reader folder by default. Create that folder and paste the file in it. Now, save the file in the same folder as OLERead.php.
Now, copy the entire Spreadsheet folder from SpreadsheetExcelWriter package, and paste it in the Excel folder in PHPExcelReader package. This 'Excel' folder in the PHPExcelReader package is what we will be using for reading from an excel file using PHP. Once you have done all this copying and pasting, you are all set to read an Excel sheet!!

Step I: Create a simple HTML file 'importexcel.html' to take the excel sheet as an input:
<form action="import.php" enctype="multipart/form-data" method="post">
File Name: <input type="file" name="file" id="file">

<input type="submit" name="Submit" value="Submit" />

Step II: Create a PHP file 'import.php', where we write the action part for the above form:


mysql_connect(hostname,username, password) OR DIE ('Unable to connect to database! Please try again later.');
include 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();


for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
$sql .= "`" . mysql_escape_string($data->sheets[0]['cells'][1][$j]) . "`,";
$sql = substr($sql, 0, -1) . ") VALUES\r\n";
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
  $sql .= "(";
  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
  $sql .= "" . mysql_escape_string($data->sheets[0]['cells'][$i][$j]) . ",";
$sql = substr($sql, 0, -1) . "),\r\n";
$sql =  substr($sql, 0, -3) . ";";
echo $sql;



Make sure that you have the 'Excel' folder in the root directory.

If you look at the output of the code, it will print the INSERT query, which is then used in mysql_query to execute the query.

Whats a take away from this tutorial is that, you can access the entries from the Excel sheet by creating an object ('$data' in our example) of Spreadsheet_Excel_Reader class, and then use this object as $data->sheets[<sheet number>]['cells'][<row number>][<column number>] to access the (row,column)th entry of  the corresponding sheet number in the excel.
Once you can access these entries, you can use them in whichever way you want....creating a table in html, or inserting those entries in a database, or any other processing.

Thats it!! Simple it was, wasn't it? Now, go ahead...use this code to read an Excel sheet....njoy!!

Have Queries?? Post it on our Discussion Forum Compild

Monday, 29 April 2013

Root Samsung Galaxy S2 GT-i9100 Jelly Bean and install Clockwork Recovery Mod

With the official Jelly Bean update now available for Galaxy SII, one thing that any android fan would be looking for would be 'How to Root it?'. Rooting the phone unleashes the true power it withholds, making the Android experience all the more exiting! Also, once you root your phone, one very basic thing you need is the Clockwork Recovery Mod.
The below tutorial gives the detailed steps for doing just the same.
The advantage of this method is that, as in the normal rooting, there is no yellow triangle that appears on your booting screen.

Make sure you have following things in place:
  • This guide is for Samsung Galaxy SII GT-i9100 (international version) only. I have not tried this out on any other version
  • Take a backup of whatever you contacts, messages etc. You  may not be able to take a system backup, as this requires rooted phone
  • Ensure that the phone has atleast 85% battery charge
Have queries?? Get them resolved...

If you have the above things set, then you are ready for what follows...

But first thing first:
Disclaimer: The instructions provided in this guide are meant for reference purpose only. I will not be held liable if the device is damaged during the installation. Users must proceed at their own risk.

This thing hardly takes about 5-10 minutes:

Files needed:
1. it from the download box alongside)
2. Clockwork Recovery Mod

And here are the steps:
  1. Place both the files in SD card and boot the phone in recovery mode. To do this, power off your phone & then long press the Volume down + Power + Home buttons simultaneously
  2. You would now be in the stock recovery mode. Now select 'Apply Update from External Storage' and then navigate to the '' file, and select it using the Power button. Select Yes in the next step...This would now root your phone
  3. Once done, again navigate back to the home screen of the stock recovery, and select 'Apply Update from External Storage'....this time, select the Clockwork Recovery Mod file
  4. This would now replace your stock recovery by the Clockwork Recovery Mod
  5. You can now play around with the various options available in the CWM, like taking a Nandroid backup
  6. Now, reboot your phone
  7. In the list of your applications, you would now see a 'Super User' App. If you are able to see this app...congrats!!... your phone is successfully rooted!
You can now install various apps like the Titanium backup, and other such apps, to tweak the performance of your phone. Once rooted, you also have the luxury to install a number of cool custom firmwares, which would have otherwise required a rooted phone...njoy:)

Now, if you wish to unroot your phone, all you need to do is flash the official Jelly Bean Rom using Odin, and there would be no traces, to prove that your phone was ever rooted!!

Have queries?? Get them resolved on our Discussion Forum Compild

Friday, 8 March 2013

Multi Window and Ripple Lock Screen for Samsung Galaxy S2 GT-i9100 Jelly Bean(4.1.2)

Samsung recently rolled out the JellyBean 4.1.2 update for Galaxy S2. The S2 users, including myself were eagerly awaiting this upgrade, and the cellphone giant Samsung did not disappoint. The JB for S2 breathes in a new life in the phone with the new Nature UX interface, Google Now, and many other exciting things added to the already feature filled Samsung flagship device Galaxy S2.

Have queries?? Get them resolved...

All said and done, there was still a major update that the S2 users were looking forward to....the much famed 'Multi-Window' feature, as in Galaxy S3 and Note2. This was not included in the JB update for S2, which for me was a let down!!
I tried to search for methods to get multi window for my phone....did so much things in that process that at one time, my phone refused to boot back!!
But then I found out these two methods....

  • 'Installing Mods for the Stock JB firmware'(This method is for the Stock JellyBean)
  • Using Deodexed XWLS8 ROM and applying the MODs on it
 by virtue of which I installed Multi window on S2 successfully....and it is running great!!

There are other methods too, but for that, you need a custom ROM(deodexed XXLSJ).

In this post I would share both these methods of installing the Mods for Galaxy S2 for Multi Window and Ripple Lock Screen.

This process requires the following things in place:
  • It was tried and tested only for the International version of galaxy S2(GT-i9100), running XWLS8 Jelly Bean 4.1.2. I'm not sure about the rest of the versions
  • The Galaxy S2 must be Rooted
  • You must have the Clockwork Recover Mod (CWM) installed (You can download the CWM form:
  • Take a NANDROID backup of your phone, just in case some unexpected problem arises
  • Ensure that the phone has atleast 85% battery charge
As usual, comes the disclaimer:
The instructions provided in this guide are meant for reference purpose only. I will not be held liable if the device is damaged during the installation. Users must proceed at their own risk.

Though I have given two methods to get Multi Window for Galaxy SII, I personally prefer Method 2.

Method 1: 'Installing Mods for the Stock JB firmware'

Files Required:
Alliance Mods for Galaxy S2

Step 1: Download the Mods from MultiWindowMods
Step 2: Place the downloaded file in your Sdcard.
Step 3: Now, reboot into Recovery mode. To do this, Power off your phone, and then press the
Volume Up+ Home+ Power button simultaneously.
Step 4: Now, once you are in Clockwork recovery, select 'Install from Zip' option
Step 5: Now, select the file that we downloaded in step 1
The features will now be installed
Step 6: Now, go back and select Reboot
Step 7: Your phone will now reboot

And, its done!! You will now be graced with a Ripple Lock screen. You now need to enable the Multi Window option from the Display Section and you are all set to boast of a Multi Window!!
Also, a section called Alliance Control will be added to the Settings, wherein you can customize the lock screen and other features. Take care not to select the Alliance OTA option as it may mess up your phone.
Snapshots from Method 1

Method 2: Using Deodexed XWLS8 ROM and applying Multi Window Mods

Files Required:
Deodexed XWLS8 ROM
Multi Window Mods

Step 1: Download the Deodexed XWLS8 ROM from DeodexedXWLS8
Step 2: Place the downloaded zip file in sdcard
Step 3: Reboot into Clockwork Recovery Mode
Step 4: Select install from zip, & then select the zip folder downloaded in Step 1
            The deodexed ROM will now be flashed
Step 5: Once done, reboot the would be graced with the Ripple Lock Screen
Step 6: Download the Multi Window Mod from Multi_Window_Mods
Step 7: Place the zip file in sdcard and again Reboot into Clockwork recovery mode
Step 8: Select install from zip, and select the zip file for mods downloaded in Step 6
Step 9: The Mods will now be installed
Step 10: Once done, reboot the phone

Thats it!! Select the Multi Window option from Settings ->Display section and you are all ready to start enjoying the magic of Multi Window!!

I preferred Method 2 over 1 for the simple reason, as I now have a deodexed ROM, which gives me greater freedom to play around with my phone, and I don't need to worry about the Alliance Mods!!
Snapshots from Method 2:

Have queries?? Stuck anywhere?? Post all the issues on Compild

Tuesday, 2 October 2012

Creating a Barcode in PHP

Leave a Comment

A barcode is an optical machine-readable representation of data relating to the object to which it is attached. Originally barcodes represented data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D).
A Barcode is generally used to map a product to its characteristics. For example, a barcode is commonly used to identify the product code, and map the unique code to the price of the product in the database. This barcode is a widely used technique.
Creating a barcode is a fairly easy job, provided you have the right font for it. I found one, with relative ease, and guess was free of cost!! I have added the font file in folder, which can be downloaded from the download box present in the sidebar. I really want to thank the creator of this font, for his hardwork, and also making his work available free of charge.
Once you have the right font, the rest is quite an easy job. we will use the basic function in PHP, viz

imagettftext($img, $fontsize, $angle, $xpos, $ypos, $color, $fontfile, $text);
Now, create a PHP file, which I have named as index.php in my case.

Include the following code in the file:


$number = '*8108137*';

$barcode_font = 'FRE3OF9X.TTF';

$width = 200;
$height = 80;

$img = imagecreate($width, $height);

// First call to imagecolorallocate is the background color
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);

// Reference for the imagettftext() function
// imagettftext($img, $fontsize, $angle, $xpos, $ypos, $color, $fontfile, $text);
imagettftext($img, 36, 0, 10, 50, $black, $barcode_font, $number);

//imagettftext($img, 14, 0, 40, 70, $black, $plain_font, $number);

header('Content-type: image/png');


Here, in this code, the code for which barcode needs to be generated is stored in the $number variable. Care needs to be taken that the code starts and ends with an asterisk (*). The barcode scanner starts looking for an asterisk, and then scans ahead of * till it reaches the ending *.
For example, if the code is 1234567, it is represented as *1234567*.
Now, this number, or code can be passed from another page, using the GET method of PHP.
Your code is now ready!! Open your project in localhost, and see your code generating a Barcode!! 

If you found the post helpful, please share!!

Saturday, 14 July 2012

Secure Login Code using PHP and MySQL / Preventing SQL Injection using PHP

Many Web pages accept parameters from web users and generate SQL queries to the database. SQL Injection is a trick to inject SQL script/command as an input through the web front end.

Your application may be susceptible to SQL Injection attacks when you incorporate invalidated user input into the database queries. Particularly susceptible is a code that constructs dynamic SQL statements with unfiltered user input.

Consider the following example code:
Sql DataAdapter myCommand = new SqlDataAdapter(
"Select * from Users
Where UserName = ' "+txtuid.Text+" ", conn);

Attackers can inject SQL by terminating the intended SQL statement with the single quote character  followed by a semicolon character to begin a new command and then executing the command to their choice. Consider the following character string entered into the .txtuid field.
' OR 1=1
This results in the following statement to be submitted to the database for execution:
SELECT * FROM Users WHERE UserName = ' ' OR 1 = 1;

Because 1=1 is always true, the attacker retrieves very row of data from the user table.

Now, to prevent such an attack, a secure login technique is required. Here, in this article, we discuss the coding of a secure login script using PHP and MySQL.

Step I: Create a database and a table 'members' in it:

CREATE TABLE `members` (
  `username` varchar(20),
  `password` varchar(128)

Step II: Create a Login Form:

<form action="process_login.php" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" value="Login" />

Connect to MySQL Server:

$host = 'localhost'; // Host name Normally 'LocalHost'
$user = 'root'; // MySQL login username
$pass = ''; // MySQL login password
$database = 'test'; // Database name
$table = 'members'; // Members name
mysql_connect($host, $user, $pass);

Step III: Now, you need to provide mechanism to avoid SQL Injection. For this, escape special characters like ", ', \

We can escape special characters (prepend backslash) using mysql_real_escape_string or addslashes functions. In most cases PHP will this do automatically for you. But PHP will do so only if the magic_quotes_gpc setting is set to On in the php.ini file.
If the setting is off, we use mysql_real_escape_string function to escape special characters. If you are using PHP version less that 4.3.0, you can use the addslashes function instead.

name = mysql_real_escape_string($_POST['username']);
$password = md5($_POST['password']);
$result = mysql_query("SELECT * FROM $table WHERE username = '$username' AND password = '$password'

Here, we use the MD5(Message Digest 5) Algorithm, that generates the message digest for the password. So, while writing the script for registration page, care must be taken that the md5 of the password entered by the user must be stored in the database, instead of the actual text password.

Validating the login:

  // Login
  $_SESSION['username'] = htmlspecialchars($username); 
  // Invalid username/password
  echo '<p><strong>Error:</strong> Invalid username or password.</p>';
// Redirect

You are done!! This code will help prevent the SQL injection problem. However, it must be noted that no script is 100% secure. So, it is advisable to provide multilevel security process, which make the login more secure.


Wednesday, 11 July 2012

Auto Refresh a Web Page using AJAX

AJAX is nothing but Asynchronous JavaScript and XML. It is not a new programming language, but a new way to use the existing standards. It is the art of exchanging data with a server, and updating parts of a web page without reloading the whole page!!

Ajax is not a single technology, but a group of technologies. HTML and CSS can be used in combination to mark up and style information. JavaScript and XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.

 Using JavaScript for periodically refreshing a page can be quite annoying, as the entire page reloads time to time. Hence, a better option would be to use AJAX.
Include the following code in the <head> section of the page....

<script src="
var auto_refresh = setInterval(
 $.ajaxSetup({ cache: false });
}, 20000);

The section now refreshes after every 20 seconds. You can change the 20000 value to suite your requirements.
You can remove the ".fadeOut('slow')" and ".fadeIn(Slow)" parts if you want the page to be refreshed unnoticed.

Now, whichever section you want to be refreshed, must be included within the <div id="loaddiv"> tags as follows:

<div id="loaddiv">
<!--Your Content goes here-->

You are now done!! Enjoy as your page refreshes without you noticing!!


Sunday, 8 July 2012

Checking if your Computer has been violated and infected with DNS Changer

Leave a Comment
Domain name system (DNS) is the part of the internet that links a website name (say to its numerical internet protocol equivalent (say 123.456.789.098). As the cyber world awaits Monday, when the FBI will shut down servers affected by the DNS changer malware, there is still a day to check if your system has been affected.
Various cyber security firms are offering free solutions. You can visit to check if your computer is infected.
You can also manually check if your DNS server has been changed.

Step I: Open Command Prompt.
           Navigate to Start-> Run.  Type cmd and hit enter.

StepII: (For Windows XP)Type ipconfig/all and hit enter.
           (For Windows 7) Type ipconfig/allcompartments/all and hit enter.

Step III: (For Windows XP) The command you entered displays information about your computer’s network settings. Read the line starting with "DNS Servers". There might be two or more IP addresses listed there. These are the DNS servers your computer uses. Write down these numbers.

(For Windows 7) The output will be very long, since Windows7 by default has support for IPv6. Most likely, you want to look for the IPv4 information under the section entitled “Ethernet adapter…”. Look for the “DNS Servers” line, and write down these numbers. There may be two IP addresses listed there.

Step IV: Check if your DNS settings are OK

Compare your DNS settings with the known malicious Rove DNS settings listed below:
Starting IP Ending IP CIDR

 What if you are infected?
If you computer is infected, please refer the page that list tools to clean DNS Changer and other self help guides to clean your computer –

Monday, 2 July 2012

How to create CAPTCHA using PHP

CAPTCHA:  Completely Automated Public Turing Test To Tell Computers and Humans Apart.

A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown alongside, but current computer programs can't:

The term CAPTCHA (for Completely Automated Public Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University.

Generating a simple CAPTCHA and its verification is quiet a simple task using PHP. In this post, I would do the same, but the CAPTCHA generated would be a simple one, while the reader can add his own creativity to it later!!

  • Step I: Create a file captchaimg.php, and add the following code to it:

header("Content-Type: image/png");
$text=substr(md5(uniqid(rand(), true)),0,5);
$_SESSION["vercode"] = $text; 
$height = 25; 
$width = 65; 
$image_p = imagecreate($width, $height); 
$black = imagecolorallocate($image_p, 0, 0, 0); 
$white = imagecolorallocate($image_p, 255, 255, 255); 
$font_size = 14; 
imagestring($image_p, $font_size, 5, 5, $text, $white); 
imagejpeg($image_p, null, 80); 

You can check the above file by opening it in your browser. Everytime you refresh, a new, random alphanumeric string is generated in the CAPTCHA.
  • Step II: Create a form form.php, and add the following code to it:
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')
     echo  '<strong>Incorrect verification code.</strong>'; 
  } else { 
     // add form data processing code here 
     echo  '<strong>Verification successful.</strong>'; 
<form action="form.php" method="post"> 
Comment: <input type="text" name="coment"> 
Enter Code <img src="captchaimg.php" /><input name="vercode" type="text" /> 
<input name="Submit" type="submit" value="Submit" /> 

Now, this is it!! Your basic CAPTCHA is ready!! It will look like below:

Another Example:
For this, you need to include a font file in your project folder. I have used AngelicWar.ttf. Download the font from the download box alongside.
Now, Overwrite the file captchaimg with the following code:

header("Content-type: image/png");
$im = imagecreate(105, 50); //Size of the image Width, Height

imagecolorallocate($im, 167, 218, 239);  //Set background color 
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);        

$font = 'AngelicWar.ttf'; // You can replace font by your own        
for($i=0;$i<=5;$i++) {
    $numb=substr(md5(uniqid(rand(), true)),0,1);
    $angle=rand(-25, 25);
    imagettftext($im, 20, $angle, 8+15*$i, 30, $black, $font, $numb);    
    // Add shadow to the text    
    imagettftext($im, 20, $angle, 9+15*$i, 34, $grey, $font, $numb);    

Now, this will result in following CAPTCHA:

For the following CAPTCHA use cheapink.ttf from the download box alongside.

You can enhance it by using two different strings in a single CAPTCHA image, or using some string characteristics.

Want help in creating more creative CAPTCHA?? Feel free to Contact Me.


Friday, 15 June 2012

Connecting C# to MySQL database / C# connection String for MySQL

Leave a Comment
In many cases it becomes imperative to connect C# to MySql, the prominent reason being the inherent simplicity of MySql. We have generally used the usual connection string to connect PHP to MySql. Connecting C# to MySql is similar.
We first need to use the connection string to establish the connection with MySql. Then, we use the SQL queries to carry out the Creation, Insertion, Update & Delete operations.

Before we do anything, first you need to download and install mysql-connector. You can get this connector from MySQL :: Download Connector/Net.

Once you install this connector, you need to add it as a reference in your C# project. You can do this by navigating to Project -> Add Reference. Then go to the .Net tab, and search for MySql.Data, and add it as a reference.

Now you need to include MySql.Data.MySqlClient at the start of the code. Add this at the start:
using MySql.Data.MySqlClient;

Now, you can use this connection string for establishing the connection:
string MyConString = "SERVER=localhost;" +    "DATABASE=dbname;" +    "UID=root;" +    "PASSWORD=\"\";";
MySqlConnection con = new MySqlConnection(MyConString);


Now, you can use 'con' when you need to fire any query.

Now, lets get into details of using sql queries.


   string query = "CREATE TABLE table_name";
   MySqlCommand cmd = new MySqlCommand(query, con);
   catch(Exception e)

   string query = "INSERT INTO table_name (attributes) VALUES(values)";
   MySqlCommand cmd = new MySqlCommand(query, con);
   catch(Exception e)

   string query = " UPDATE table_name
   SET column1=value1, column2=value2, ...
   WHERE some_column=some_value";
   MySqlCommand cmd = new MySqlCommand(query, con);
   catch(Exception e)

   string query = "DELETE FROM table_name WHERE some_column=some_value";
   MySqlCommand cmd = new MySqlCommand(query, con);
   catch(Exception e)


   MySqlCommand query = new MySqlCommand("Select * FROM `table_name` where
   CONDITION, con);
   MySqlDataReader reader = con.ExecuteReader();
   while (reader.Read())

Finally, you need to close the connection, after you finish executing the queries. You can do this by writing:



Friday, 1 June 2012

Generating a Unique Hardware Fingerprint for Software Licensing

1 comment
Generating a hardware fingerprint is the most commonly sought technique to ensure security in case of softwares. There can be various methods of generating the hardware fingerprint, using different languages. However, the important thing to decide is, which devices to consider while generating the fingerprint.

For licensing purposes, the best and secure way is to generate a unique key for the client's machine and provide a corresponding license key for that key. The key can be generated using the unique id of the client's computer motherboard, BIOS and processor. When you get these IDs, you can generate any key of your preferable format.

In this post, I will get into the details of generating the unique fingerprint for the user's system.

Step I: Adding References:

First of all, you need to add the following references to your project.
1. System.Drawing
2. System.Management
3. System.Windows.Forms
For doing this, navigate to Project in the Menu Bar--> Add References-->.Net

Step II: Starting to Code

Add the following code at the start.
using System;
using System.Threading;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Data;
using System.Drawing;

namespace Aj_fingerprint
    public class Aj_fp
        public static void Main(string[] args)
            Aj_Fingerprint f = new Aj_Fingerprint();
            string fp = f.Value();

    public class Aj_Fingerprint
        public string Value()
            return pack(cpuId()+ biosId()+ diskId()+ baseId()+ videoId()+ macId());
        private string biosId()
            return identifier("Win32_BIOS", "Manufacturer")
            + identifier("Win32_BIOS", "SMBIOSBIOSVersion")
            + identifier("Win32_BIOS", "IdentificationCode")
            + identifier("Win32_BIOS", "SerialNumber")
            + identifier("Win32_BIOS", "ReleaseDate")
            + identifier("Win32_BIOS", "Version");

        private string cpuId()
            string retVal = identifier("Win32_Processor", "UniqueId");
            if (retVal == "")
                retVal = identifier("Win32_Processor", "ProcessorId");

                if (retVal == "")
                    retVal = identifier("Win32_Processor", "Name");

                    if (retVal == "")
                        retVal = identifier("Win32_Processor", "Manufacturer");

                    retVal += identifier("Win32_Processor", "MaxClockSpeed");

            return retVal;


        private string diskId()
            return identifier("Win32_DiskDrive", "Model")
            + identifier("Win32_DiskDrive", "Manufacturer")
            + identifier("Win32_DiskDrive", "Signature")
            + identifier("Win32_DiskDrive", "TotalHeads");

        private string pack(string text)
            string retVal;
            int x = 0;
            int y = 0;
            foreach (char n in text)
                x += (n * y);

            retVal = x.ToString() + "00000000";

            return retVal.Substring(0, 8);

        private string videoId()
            return identifier("Win32_VideoController", "DriverVersion")
            + identifier("Win32_VideoController", "Name");

        private string baseId()
            return identifier("Win32_BaseBoard", "Model")
            + identifier("Win32_BaseBoard", "Manufacturer")
            + identifier("Win32_BaseBoard", "Name")
            + identifier("Win32_BaseBoard", "SerialNumber");

        private string macId()
            return identifier("Win32_NetworkAdapterConfiguration", "MACAddress", "IPEnabled");

        private string identifier(string wmiClass, string wmiProperty)
            string fprint = "";
            System.Management.ManagementClass aj_mc = new System.Management.ManagementClass(wmiClass);
            System.Management.ManagementObjectCollection aj_moc = aj_mc.GetInstances();
            foreach (System.Management.ManagementObject aj_mo in aj_moc)
                if (fprint == "")
                        fprint = aj_mo[wmiProperty].ToString();
                    { }
            return fprint;

        private string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue)
            string fprint = "";
            System.Management.ManagementClass aj_mc = new System.Management.ManagementClass(wmiClass);
            System.Management.ManagementObjectCollection aj_moc = aj_mc.GetInstances();
            foreach (System.Management.ManagementObject aj_mo in aj_moc)
                if (aj_mo[wmiMustBeTrue].ToString() == "True")
                    if (fprint == "")
                            fprint = aj_mo[wmiProperty].ToString();
                        { }

            return fprint;


Now, you can use this unique hardware fingerprint in further hashing, to authenticate the user system!!

You can for further assistance.

Tuesday, 1 May 2012

Solution for "Installation Error 0X80004002"

I was having a tough time installing Google Drive. When the setup was run, it gave an error message saying Google Update Installation failed, with error 0X80004002. This error is very common & occurs while installing Google products, like Chrome, Drive.
I tried to search for the solution but in vain. So I took a seemingly daring way, to solve this problem, and guess worked!!!
Though this seems to be a crude way, it worked for me:

1. I Uninstalled all the Google related softwares from my PC, like Chrome, GTalk, Google Earth, Picasa.
2. Then open Run, and type regedit. This opens the Registry Editor.
3. Browse to HKEY_CURRENT_USER in the side bar.
4. Browse Software, and look for Google.
5. Right Click, and select DELETE.
6. Now close the Registry Editor, and try to install the Google related application again.

Had a tough time while reinstalling all my other Google applications though!!

Please contribute, if you have any better solution!!

For me, it worked...hope it works for you!!

You can for further assistance.

Saturday, 31 March 2012

Sending email using PHP...(PHPMailer)

1 comment
Sending emails using PHP is an easy task...Just a few steps and you are through!!

Step I: Download PHPMailer
The very first thing that needs to be done is, downloading the PHPMailer package. This package contains all the methods for sending simple mails, to sending mails with attachments!!
You can download the package from: PHPMailer

Step II: Starting to Code
Create a new php file test.php and copy the following code:
(Note: test.php file should be in the same folder as the extracted PHPMailer package)

The above code uses the gmail SMTP server...You have to mention the username and password of your gmail account!!

This is it!! You are now all ready to send mail!!

My next post will include sending attachments in emails....and also using mail() method!! So, keep visiting!!

You can for further assistance.

Tuesday, 7 February 2012

Macromedia Flash 8

Leave a Comment
Flash is a drawing and animation package designed to work with vector graphics. It creates animations which can include sounds, music and interactivity, and which are optimised for use on the web. Hence, the files it produces are small and designed for streaming. Furthermore, all the elements which form part of a flash movie are embedded within the movie. This means that, unlike a standard web page which relies on the fonts and resources on the client machine, as long as the user has the flash player installed, the movie will play exactly as you design it.
                The default file extension for a Flash file is .fla. Flash movie files can also be published in .htm, .swf, .jpg, .exe, .png or as a projector file.


§  Toolbox:
The toolbox contains all tools necessary for drawing, viewing, coloring and modifying your objects. Each tool in the toolbox comes with a specific set of options to modify that tool. The diagram below outlines the grouping of tools.

Sunday, 5 February 2012

Autodesk MAYA

Leave a Comment


Maya is the 3-D animation software that provides a number of tools for creating complex characters and animations. Maya's powerful feature set gives us the flexibility to create any kind of animation. The functionality of the Maya software can be extended with the use of MEL (Maya embedded language). MEL can be used to customize the user interface and write scripts and macros. 
Maya can create objects, lights, cameras and textures. Any object, light, camera, or just any entity can be animated by changing the value of its parameters in time. We can use Maya, to create effects or animations or movies, commercials, architectural animation and forensic animation.


Maya user interface looks provides a large number of functions and the scope to add more functions to the user interface which provides the real flexibility to the program. Along with the common functions there are set of functions dedicated to a more specific task like modeling, texturing, animation, rendering etc. The default Maya user interface can be divided into the following sections.
  • Main Menu Bar
Tools and items are accessible from pull down menus located at the top of the user interface. In Maya, menus are grouped into menu sets. These menu sets are accessible from the Main Menu bar.

  • Status Line
The Status Line, located directly below the Main Menu bar, contains a variety of items, most of which are used while modeling or working with objects within Maya. Many of the Status Line items are represented by a graphical icon. The icons save space in the Maya interface and allow for quick access to tools used most often.

  • Shelf
It contains different tools and commands which are used to organize commonly used functions and tools into groups. Different shelves can be created for different functions like modeling, animation, texturing etc with the required tools for each function.

  • Tool Box
Maya Tool Box contains common tools as well as layout buttons for changing views and layouts. The tool box contains:
- Select tool to select a particular object or a group of objects together.
- Lasso tool is used to draw a free hand border around the objects to be selected.
- Move, Rotate and Scale tools are used for transforming objects in Maya.
- Soft Modification tool is used to select the sub-object elements and modify them by
  moving, rotating or scaling in a way that the neighboring sub-objects also get affected
  by this deformation with the effect being an inverse of distance from the primary
  selected sub-objects.
- Last Selected tool section shows the last used tool for easy access.
- Single Perspective view button lets you view the workspace as a single large view from a single perspective.
- Four Views can be used to view the workspace in four sections with each section containing the three orthographic views top, side and front and a perspective view respectively.
Other combination options below these tools are used to divide the workspace into different section in such a way that one section contains the view of the scene and other contains an animation or rendering editor so that you can edit the attributes and watch the results simultaneously.

  • Workspace
The Workspace displays by default in a perspective window or panel. The purpose of using workspace is to view your scene. The workspace can be divided into sections to accommodate the orthographic and perspective views of the scenes as well as the different editors for animation, texturing and rendering etc.

  • Panel Menus
Every view panel has a common set of menus at the top.

  • Time Slider & Range Slider
The Two Sliders are for controlling the frames in your animation. The Time Slider includes the playback buttons and the current time indicator. The Range slider includes start and end times and allows animators to focus on a specific part of the animation.

  • Command Line
The command Line lets you enter the MEL (Maya embedded Language) commands to perform various functions. The left side is where you can type MEL commands and the right half displays system responses, error messages, and warnings.

  • Help Line
Like several other applications, you can look at the help line for descriptions, instructions, and other useful information. While a tool is selected, the helpline gives out a brief description for "how to" and "what for".

  • Channel box
The Channelbox is on the right side of the screen. In this menu you will find all the properties of selected objects, and you can change those properties. If you apply a certain command on an object, Maya will remember this. This is called the history of an object and that is also shown here.

  • Layer editor
It helps in working with different layers in an animation. Objects can be placed in different layers and can be edited using this tool.


Fluid Effects

A realistic fluid simulator effective for simulating smoke, fire, clouds and explosions.

Classic Cloth

Cloth simulation to automatically simulate clothing and fabrics moving realistically over an animated character.


Animal fur simulation similar to Maya Hair. It can be used to simulate other fur-like objects, such as grass.


A simulator for realistic-looking human hair implemented using curves and Paint Effects. These are also known as dynamic curves.

Maya Live

A set of motion tracking tools for CG matching to clean plate footage.


nCloth is the first implementation of Maya Nucleus, Autodesk's simulation framework. It gives the artist further control of cloth and material simulations.


nParticle is addendum to Maya Nucleus toolset. nParticle is for simulating a wide range of complex 3D effects, including liquids, clouds, smoke, spray, and dust.


This enables compositing of CGI elements with motion data from video and film sequences.


It is an interactive node based film composing solution.

Camera Sequencer

Camera Sequencer is used to layout multiple camera shots and manage them in one animation sequence.

Maya Embedded Language:

Maya has its very own cross-platform scripting language called Maya Embedded Language. MEL is used not only for scripting, but also as a means to customize the core functionality of the software, since much of the tools and commands used are written in it. Code can be used to engineer modifications, plug-ins or be injected into runtime. Outside these superficial uses of the language, user interaction is recorded in MEL, allowing even inexperienced users to implement subroutines.


Subscribe to Get Latest Tutorial via email