Sunday, May 22, 2016

Checking Given Integer is Palindrome or Not

According to  A Palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. So I am going to to show how to check whether a given integer is  Palindrome or Not using C.

OS- Linux (kubuntu 16.04)
Compiler - GCC
IDE -Codeblock

#include <stdio.h>
To check if a string is a palindrome or not,
a string needs to be compared with the reverse of itself.

int main(){
  int n;
  int reverseno = 0;
  int remainder;
  int originalno;

  printf("Please enter a integer :");
  originalno = n;

    remainder= n%10;
    reverseno= reverseno *10 +remainder;

    if(originalno == reverseno)
        printf("%d is a palindrome.", originalno);
        printf("%d is not a palindrome.", originalno);
        return 0;

Screen shot :

You can do it palindrome  check in any language like PHP, Javascript, Python, Ruby , Java , just change the code little bit .

Saturday, February 1, 2014

PHP Image upload , Saving link to Database complete tutorial

This blog is dedicated to all our visitors who asked me to publish a working tutorial on  image upload  using PHP and Saving its path to Mysql Table.
PHP Image upload , Saving  link to Database

How to do that :
First we will create a file called install.php , it will create a database called
myimages and a table  named imgtables and also create a folder called gallery where we are going to store  images.

Create a file name install.php
file name : Install.php
purpose : creating a database name myimages
and table imgtables
Create by : Sanjay Prasad


    echo "Error <br/>".$sp->error;

$query="create database if not exists myimages";

     echo "Created database myimages ..<br/>";   
                echo "Error <br/>".$sp->error;
            $tbquery="create table if not exists imgtables(
            id int unsigned auto_increment primary key,
            imgurl varchar(255),
            date varchar(100)

                echo "Table imgtables created Successfully  ..<br/> ";   
                echo "Error <br/>".$sp->error;       
            //creating directory gallery
                echo "Folder gallery create successfully";
                echo "Error Creating Directory";

    echo "Error <br/>".$sp->error;   


Now We have to create a file name gallery.php, which will upload images to folder gallery and saved their name like flower.jpg on table filed imgurl.


<!DOCTYPE html>
<html lang="en">
<title>File Uploading</title>
<meta charset="utf-8" />
                echo "Error <br/>".$sp->error;



echo " ".basename($_FILES['file_upload']['name'])." has been uploaded<br/>";
echo '<img src="gallery/'.$_FILES['file_upload']['name'].'" width="48" height="48"/>';
    $query="insert into imgtables (imgurl,date) values('$img',now())";
     echo "<br/>Inserted to DB also";   
        echo "Error <br/>".$sp->error;       

echo "There is an error,please retry or ckeck path";
<form action="gallery.php" method="post" enctype="multipart/form-data">
<table width="384" border="1" align="center">
<td width="108">Select File</td>
<td width="260"><label>
<input type="file" name="file_upload">
<input type="submit" name="upload" value="Upload File">


Friday, July 5, 2013

My way learn MySQLI and PHP by examples

MySQL is world most used database and when its works PHP then they have no match. Learning MySQL is very is one can found thousand of tutorial on net but these are now old as MySQLI(or MySQL Advanced) next version are now on demand as implementation is easy, secure and little bit faster. In this tutorial I am going to share Uses of MySQli in your next project.

MySQLI and PHP by examples

For Connecting to database, create a PHP file name dbsettings.php with following code :

$sanjay=new mysqli('localhost','root','','mysqlifirst');
     echo $sanjay->connect_error;

I think above line is quite easy to understand, mysqlifirst is the name of your database.

Data query :
Suppose you have a table name billings which has coloumn trans_id, amount and so on.
Create a another file name dataquery.php with following code:

$query="select * from billings where trans_id='2013' ";
echo "Transaction ID. 2013 amount is Rs.".$rows['amount'];

This is I think a very simple example of using MySqli. If you have any doubt then comment below , I will try to explain it later.
+Sanjay Prasad 

Wednesday, May 8, 2013

SCRA Detail Syllabus for year 2013-2014

Special Class Railway Apprentices (SCRA) - 2013-2014 

+Sanjay Prasad 


Paper I General Ability Test 2 Hours 200
Paper II Physical Sciences 2 Hours 200
Paper III Mathematics 2 Hours 200


General Knowledge 

For General Knowledge read books of SCHAND, UPKAR, TATA .

Constitution of India and its characteristic features:
Democracy, Secularism, Socialism, equality of opportunity and Parliamentary form of Government. Major political ideologies - Democracy, Socialism, Communism and Gandhian idea of non-violence. Indian political parties, pressure groups, public opinion and the Press, electoral system.
India’s foreign policy and non-alignment, Arms race, balance of power. World organisation - political, social, economic and cultural. Important events (including sports and cultural activities) in India and abroad during the past two years.
Broad features of Indian social system: The caste system, hierarchy, recent changes and trends. Minority social institution - marriage, family, religion and acculturation. Division of labour, co-operation, conflict and competition, Social control - reward and punishment, art, law, customs, propaganda, public opinion, agencies of social control - family, religion, State educational institutions; factors of social change -  economic, technological, demographic, cultural; the concept of revolution.
Social disorganisation in India: Casteism, communalism, corruption in public life, youth unrest, beggary, drugs, delinquency and crime, poverty and unemployment. Social planning and welfare in India, community development and labour welfare; welfare of Scheduled Castes and Backward Classes.
Money: Taxation, price, demographic trends, national income, economic growth. Private and Public Sectors; economic and non-economic factors in planning, balanced versus imbalanced growth, agricultural versus industrial development; inflation and price stabilization, problem of resource mobilisation. India’s Five Year Plans.
Geography : Solar system and the earth. Seasons, Climate, Weather, Soil - its formation, erosion. Forests and their uses. Natural calamities cyclones, floods, earthquakes, volcanic eruptions. Mountains and rivers and their role in irrigation in India. Distribution of natural resources and industries in India. Exploration of underground minerals including Oil. Conservation of natural resources with particular reference to the flora and fauna of India.
Science : Knowledge of the human body, nutrition, balanced diet, substitute foods, public health and sanitation including control of epidemics and common diseases. Environmental pollution and its control. Food adulteration, proper storage and preservation of food grains and finished products, population explosion, population control. Production of food and raw materials. Breeding of animals and plants, artificial insemination, manures and fertilizers, crop protection measures, high yielding varieties and green revolution, main cereal and cash crops of India.Evolution of life, plants and animals, heredity and environment-Genetics, cells, chromosomes, genes.

This is test understanding and command of the language of candidates. Use SCHAND English book.

complex number
Matrices and Determinants
Permutation and Combination
profit and loss
quadratic equation

Addition and subtraction formulae, multiple and sub-multiple angles. Product and factoring formulae. Inverse trigonometric functions - Domains, Ranges and Graphs. DeMoivre's theorem, expansion of Sin n0 and Cos n0 in a series of multiples of Sines and Cosines. Solution of simple trigonometric equations. Applications: Heights and Distance. 

Rectangular Cartesian. Coordinate system, distance between two points, equation of a straight line in various forms, angle between two lines, distance of a point from a line. Transformation of axes. Pair of straight lines, general equation of second degree in x and y - condition to represent a pair of straight lines, point of intersection, angle between two lines. Equation of a circle in standard and in general form, equations of tangent and normal at a point, orthogonality of two cricles. Standard equations of parabola, ellipse and hyperbola - parametric equations, equations of tangent and normal at a point in both cartesian and parametric forms. 

Integral Calculus and Differential equations
Vectors and its applications 

Frequency distribution, cumulative frequency distribution - examples. Graphical representation - Histogram, frequency polygon - examples. Measure of central tendency - mean, median and mode. Variance and standard deviation - determination and comparison. Correlation and regression. 


Wednesday, March 20, 2013

upload user profile image and save to data base -PHP MYSQLI

   If you are working on customized CMS or Social networking website then user profile image may be or may not be a head ache I have developed my own where we can upload and rename the image username.jpg/png/gif with size restriction to 200KB.

PHP MYSQLI Upload Image Tutorial

First design a table where database name is Sanjay.
Create a table userImage  fileds
user - username will be stored
url - url of img stored
lastUpload- when the upload was done.
create a folder upload/   where  all images will stored.
$db=new mysqli('localhost','root','','Sanjay');
echo $db->connect_error;}
$pull="select * from userImage  where user='$user'";

$allowedExts = array("jpg", "jpeg", "gif", "png","JPG");
$extension = @end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/JPG")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 200000)
&& in_array($extension, $allowedExts))
  if ($_FILES["file"]["error"] > 0)
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    echo '<div class="plus">';
    echo "Uploaded Successully";
    echo '</div>';
    echo"<br/><b><u>Image Details</u></b><br/>";
    echo "Name: " . $_FILES["file"]["name"] . "<br/>";
    echo "Type: " . $_FILES["file"]["type"] . "<br/>";
    echo "Size: " . ceil(($_FILES["file"]["size"] / 1024)) . " KB";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      unlink("upload/" . $_FILES["file"]["name"]);

      "upload/". $user.".".$ext);
      echo "Stored in as: " . "upload/" . $user.".".$ext;
      $query="update userImage set url='$url', lastUpload=now() where user='$user'";
          echo "<br/>Saved to Database successfully";
  echo "File Size Limit Crossed 200 KB Use Picture Size less than 200 KB";

<form action="" method="post" enctype="multipart/form-data">   
    echo '<div class="imgLow">';
    echo "<img src='upload/$pics[url]' alt='profile picture' width='80' height='64'   class='doubleborder'/></div>";
    <input type="file" name="file" />
    <input type="submit" name="pupload" class="button" value="Upload"/>

Hope You will understand this simple script.

if you want complete script with foundation framework, profile mangement, password change, user profile picture management then download my open -source project Adminplus at githhub
download Zip file extract and save it to htdocs folder , if using Linux set permission . open phpmyadmin and create a database sanjay_plus now import  sql . Now we can login using username sanjay password

USSD base balance check on Linux using datacard

If you are Indian Data card user, having data card of micromax, beetal,huwai,zte we have always option to check your balance on windows OS as they provide software for that but what about Linux. I accept the pleasure of using that software is quite awesome but still we can check our data card balance on linux using a free app called Prepaid Manager.

Linux Prepaid Manager

First Install Prepaid Manager. Installing will not let you to use these app. You have also install a configuration file in which all settings are there called serviceproviders.xml

First Install libxml2-utils
sudo apt-get install libxml2-utils
if faile use command su instead of sudo.

open file manager in admin mode
 sudo nautilus
or sudo namo .....
whatever your file manager is
and search for serviceproviders.xml open in text editor
look for your service provider.
where to search this file

First Look for your operator like Aircel, Vodafone, Relaince .....

Example of Aircel
and add before <apn></apn> tag


     <ussd replacement="CODE">*130*CODE#</ussd>

Save the file and use Prepaid manager software.