Creating PHP MySQL Development Enviroment with XAMPP

 XAMPP stands for X(Windows or Linux),Apache,MySQL,PHP and Perl.All these are bundled in XAMPP package.

So let start our tutorial for installing XAMPP.
XAMPP is free software you can download it from the website

http://www.apachefriends.org/en/xampp-windows.html


start installer and check all click next .




You can change location of XAMPP folder or make default created by xampp installer and start installation.







After  complete installation, click on the xamp control and start Apache and Mysql .













 .


 After starting ,open you web browser and check xampp is running so write http://localhost it will display Welcome page.



















XAMPP root folder is  htdocs.If you want to work with MySQL click on phpMyAdmin below Tools.


MySQL defualt user name is root and password is not set so if you want to set up user name and password for security click on security.



















Then Click on http://localhost/security/xamppsecurity.php

Write password and then click on Password Changing.


















I hope you would like this post.

Arthmetic Operations in Java

This program perform arithmetic operations on values entered by user. Program uses Scanner class of util package to get input from user. 

How to add images in PHP


// image class to add images
// image.php
<?php
class image {
function add_image($image_name,$directory_path,$file){
$flag = false;
$name = $image_name;
// upload image for in temp folder

    $image     = $file;
    $uploadDir = $directory_path;
    // if a file is given
    if (trim($image['tmp_name']) != '') {
        // generate a random new file name to avoid name conflict
    $rand_name = md5(rand() * time()) . ".$ext";
     
// move the image to  image directory

if (move_uploaded_file($image['tmp_name'], $uploadDir . $rand_name)) {

// Here write query to insert record into database such as :
// image name , image path etc

}
     else{
      $flag = false;
    }

}
else{
$flag = false;
}




return $flag;
}

}
?>

//add.php
<?php
// call the object
include("image.php");
$image_name = $_POST['name'];
$directory_path = "image/";
$ob = new image();
 $flag= $ob->add_image($image_name,$directory_path,$_FILES['fleImage']);
if($flag){
echo "Image Added Successfully";
}
else{
echo "Operation Failed";
}
?>

// Page for image form
// test.php


<html>
<body>
<form action="add.php" method="post" enctype="multipart/form-data">
 <p><h3>Add Image</h3></p>

 <table>
  <tr>
   <td>Shape Name</td>
   <td> <input name="name" type="text"  size="30" maxlength="50"></td>
  </tr>

  <tr>
   <td>Image</td>
   <td> <input name="fleImage" type="file">
   </td>
  </tr>
<tr>
<td>
  <input name="add_shapes" type="submit"  value="Add">
 </td>
 </tr>
</table>

</form>
</body>
</html>

substr() functin in PHP

substr() function is widely used to solve problem related to content in php.
For example : If you want to get specific word from sentence  so you can do it through substr and many other problem can be solved through substr.
here is syntax of substr

substr(String , Start , Length);


  • String:  String is word,sentence or paragraph which you want use for substr function
  • start :  Starting point for substr function from which it start geting characher.If word is welcome here if start parameter is 0 then it start from w , if is 1 then it start from e and onwards . 
  • Length : how many characters you want to extract ,you have to mention lenght in function . Suppose word is welcome If you write 1 there it will return only w , if 2 then we or 3 then it will return wel and onwards.
You will more cleared after running this program

<?php
               $string = "Welcome to my Blog"; // I want to extract Welcome
               $new_string = substr($string,0,7);
               echo $new_string;
?>

Hope You understand Thank You for reading.

How to add integers in java

This program will show to how to add intergers entered by user in command prompt..

For getting input number from user , java has builtin class Scanner in Util package

Package is set of related classes.

how to initiate Class for input

Scanner input = new Scanner(System.in)

After creating object of Scanner class , access  nextInt( ) method for getting input from user and assign that value to int variable.

int num1,num2,result ;
num1 = input.nextInt( ) ;
num2 = input.nextInt( );
result = num1 + num2;

after that output this result on console
here is code for adding numers

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

import java.util.Scanner;
public class add_integers{

public static void main(String[] arg){

// scanner for input
Scanner input = new Scanner(System.in);
int num1;
int num2;
int result;

System.out.println("please enter number 1");
num1 = input.nextInt();
System.out.println("please enter number 2");
num2 = input.nextInt();

result = num1 + num2;

System.out.println("Addition is "+result);
       }

}

How to set enviroment variable for java in Windows XP/7

For  executing java program java program needs to be placed in bin folder .

But if you want to execute java program without placing it in bin folder of java you have to create the enviroment variable in windows..

For creating enviroment variables

Go to

My Computer  --> Properties ->Advanced -> Enviroment Variables --> System Variables

In system variables you will see value and variable

Here is variable which name is  Path

here append full path of java.

for append just place   ;  at end  and then paste java path

Ex : C:\Program Files\Java\jdk\bin

Ex :   java folder\bin

now close cmd   .. and  include your folder where java program is saved  and execute java prgram.



Say Hello to JAVA

Java is one of the most popular programming language . Java is 100% object oriented programming means in java every program must contain atleast one class.
Java contains very rich libraries which are called packages.

Today we will say Hello world to java.. So are you ready...

First go to oracle website and download the JDK.

http://www.oracle.com/technetwork/java/javase/downloads/index.html

After downloading install JDK.

Now create a file name as Hello.java

here is hello word program code..


class Hello{
public static void main(String[ ] arg){
    System.out.println("Hello Java");

}

}


Now copy this file and paste in java bin folder.

now go to Run and  write cmd, then DOS will be open

in DOS set the path for bin file of java. Use the CD command for set the path
write command  cd\

cd :\ cd program files

cd:\ program files\cd java

cd:\ program files\java\cd bin

cd:\ program fies\java\bin

cd:\ program fies\java\bin/javac Hello.java  

cd:\ program fies\java\bin\java Hello





output

Hello Java