Sunday, 24 May 2015

Reinstall movie maker on xp

To reinstall the Movie Maker: 
  • You must be logged on as Administrator or as a member of the Administrators group in order to perform this procedure. 
  1. Click Start , click Run , and then type the following command:       
                       %systemroot%\inf

         NOTE : There are no spaces at all in the preceding command line.
  1. Click OK that will open the INF folder.
  2. you may see lots of inf files, just Locate the file moviemk.inf 
  3. Right-click on the moviemk.inf file, and then click Install . This will reinstall the files that Search needs to proceed normally.  
       NOTE- when you install, you will be prompted to locate source file from cd-rom or from another location that is needed to install movie maker.
  
That's it.
Enjoy and start your movie making using movie maker.

Still if your are unable to get this, just follow this link
Get MovieMaker from Microsoft

Wednesday, 20 May 2015

Connect mysql database with PDO statement

We all know that mysql_ extensions now are deprecated in php 5.5.x and generates E^ deprecated warning.
Because,It was originally introduced in PHP v2.0 for MySQL v3.23, and no new features have been added since 2006. Coupled with the lack of new features are difficulties in maintaining such old code amidst complex security vulnerabilities.
The manual has contained warnings against its use in new code since June 2011.

To overcome mysql_extension,  PDO can be used. here we are going to show how to connect mysql database with PDO statement.

Recap--
in mysql_ extension, we used mysql_connect to establish connection to our database.

$conn=mysql_connect("localhost","USER_NAME","PASSWORD");
if(!$conn)
{
  // echo "Connection failed..";
  header("location:error.php");
  exit;
}
if(!mysql_select_db('DATABASE_NAME'))
{
  //echo "Database selection failed..";
  header("location:error.php");
  exit;
}

In PDO We may do something like this..
try
{
 $obj_pdo=new PDO('mysql:host=localhost;dbname=DATABSAE_NAME','USER_NAME','PASSWORD');

$obj_pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
return $obj_pdo;
}
catch(PDOException $e)
{
      header("location:error.php");
      exit;
}

Explanation---
Here we are using try and catch block to control the success or failure during establishing the connection.
on success, try block will return $obj_pdo object will be used for executing other statements. 
so whenever any error occurs like username or database name or password is incorrect, the catch block will be executed. Here we are redirecting users to error.php page if it fails to establish a connection.
 
This example shows how to create connection to database only. this is the best and simple way to create a connection with database.

See also..
Why mysql_ extension is deprecated ?
How to execute INSERT query/statement with PDO statement.
How to execute SELECT query/statement with PDO statement
How to execute UPDATE query/statement with PDO statement
How to execute DELETE query/statement with PDO statement

Why prepared statement is used in PHP PDO ?

Many of the more mature databases support the concept of prepared statements. actually they can be thought of as a kind of compiled template for the SQL that an application wants to run, that can be customized using variable parameters.

Prepared statements offer two major benefits:
  • The query only needs to be parsed (or prepared) once, but can be executed multiple times with the same or different parameters. When the query is prepared, the database will analyze, compile and optimize its plan for executing the query. For complex queries this process can take up enough time that it will noticeably slow down an application if there is a need to repeat the same query many times with different parameters. By using a prepared statement the application avoids repeating the analyze/compile/optimize cycle. This means that prepared statements use fewer resources and thus run faster.
  • The parameters to prepared statements don't need to be quoted; the driver automatically handles this. If an application exclusively uses prepared statements, the developer can be sure that no SQL injection will occur (however, if other portions of the query are being built up with unescaped input, SQL injection is still possible).
Prepared statements are so useful that they are the only feature that PDO will emulate for drivers that don't support them. This ensures that an application will be able to use the same data access paradigm regardless of the capabilities of the database. 

Example--
<?php 
$your_stmt $obj_pdo->prepare("INSERT INTO table_name (field1, field2) VALUES (:field1, :field2)");
$your_stmt->bindParam(':field1'$name);
$your_stmt->bindParam(':field2'$value);

// insert one row
$name 'ABC';
$value = 10;
$your_stmt->execute();

// insert another row with different values
$name 'XYZ';
$value = 30;
$your_stmt->execute();
?>

Here we are executing execute statement 2 times while prepare statement only once.

$obj_pdo->prepare() to prepare a query to know the database that something is going to be executed.
$your_stmt->bindParam(':field1'$name); //here we are using bindParam to bind the value to field with $name variable.

$your_stmt->execute();// finally execute statement is used to execute all above stuff.

See also

Tuesday, 19 May 2015

mysql_ extension Deprecated in PHP 5.5.x- Use mysqli or PDO instead

A very popular and very easy mysql extensions now are deprecated in PHP 5.5x.

The entire ext/mysql PHP extension, which provides all functions named with the prefix mysql_, is officially deprecated as of PHP v5.5.0 and will be removed in the future.

It was originally introduced in PHP v2.0 for MySQL v3.23, and no new features have been added since 2006. Coupled with the lack of new features are difficulties in maintaining such old code amidst complex security vulnerabilities.

The manual has contained warnings against its use in new code since June 2011.

There is a way to overcome this problem is to use PDO or MYSQLi.. If you have knowledge of  OOP(object oriented programing), you may use PDO statements to overcome the problem of mysql_ deprecation.

See also
Database connection using PDO in PHP


Sunday, 17 May 2015

Use feature of TAB key using ENTER key in vb

A simple example, how to use feature of  TAB key using ENTER key in vb

Generally TAB key is used for getting focus on next object/control within form. The object / control can be textbox, command button, combo box or anything that you place on form.

So here we are using Enter key to work as a TAB key.
you may use any key to work as a TAB key if you know the ascii value of that key.

First of all, 
-> Place 2 -3 textbox  in your form.(You can place any control from design view)
->Now Double click on any of that textbox, after double clicking, you may be in Change event of that  textbox.
->now change to keypress event,  this will look like this.

Private Sub your_textbox_KeyPress(KeyAscii As Integer)
 

End Sub

->Now copy below code and paste between that two line.

If KeyAscii = 13 Then  ' The ENTER key.
            SendKeys "{tab}"    ' Set the focus to the next control.
            KeyAscii = 0        ' Ignore this key.
End If


->that will look like this


Private Sub your_textbox_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then  ' The ENTER key.
            SendKeys "{tab}"    ' Set the focus to the next control.
            KeyAscii = 0        ' Ignore this key.
         End If
End Sub


Here whenever any key is pressed within particular object/control, the KeyPress event will be called of that object. 

Keypress event will check whether key pressed is Enter key(Ascii value is 13) or not.
if it is Enter key means ascii value is 13 then it will send control to the Tab key and Enter key will be ignored.
   
So whenever you press Enter Key, your Enter key will work as a Tab key.
so you will get focus on next object.

you may use any key to work as a TAB key if you know the ascii value of that key. 

VB SOLUTION: Get unique CPU ID for all unique client - viusal basic - no need to use key.

VB SOLUTION: Get unique CPU ID for all unique client - viusal basic - no need to use key.

Get unique CPU ID for all unique client - visual basic - no need to generate setup key.

Here I am going to show you how to fetch CPU id(Unique number from CPU) using visual basic.
Remember that you have to execute below code from your client PC only once to authorized your premium client.

Copy this code and make exe file of that project and run on client pc.
Save output code either in database for future use.

Dim wmi, cpu
  Set wmi = GetObject("winmgmts:")
  For Each cpu In wmi.InstancesOf("Win32_Processor")
   cpuid = cpuid + cpu.ProcessorID
  Next

-----------------------------------------------------------

This will fetch something like BGYGHHF6BG (its an example only).

Now Implement this code in your project and compare output like this..
copy this code to

Dim wmi, cpu
  Set wmi = GetObject("winmgmts:")
  For Each cpu In wmi.InstancesOf("Win32_Processor")
   cpuid = cpuid + cpu.ProcessorID
  Next


If cpuid = "BGYGHHF6BG" Then
         frmLogin.Show
         Unload Me

Else
        MsgBox "This Is Not REGISTERED Copy....." & vbCrLf & "" & vbCrLf & "To Register Your Copy Kindly Contact To Mr. ABC ", vbCritical, "WARNING"
        Unload Me

End If

-------------------------------------------------------------------------
This code fetches and compare output every time user open your application. 

Monday, 15 April 2013