Sunday, January 22

Top 10 richest people in the world


Top 10 richest people in the world

Top 10 richest people in the world, Bill Gates at no. 1: Bloomberg ranking
  • Bill Gates
  • Amancia Ortega
  • warren Buffett
  • Jeff Bezos
  • Chaeles Koch
  • David Koch
  • Carlos Slim
  • Mark Zuckerberg
  • Larry Ellison
  • Ingvar Kamprad
Free Download

Top 10 Best Hindi Comedy Movies of All Time


Top 10 Best Hindi Comedy Movies of All Time

  • 1. Andaz Apna Apna
  • 2. Angoor
  • 3. Chupke Chupke
  • 4. Hera Pheri
  • 5. Gol Maal
  • 6. Munna Bhai MBBS and Lage Raho Munna Bhai
  • 7. Padosan
  • 8. Jaane Bhi Do Yaaro
  • 9. 3 Idiots
  • 10. Chameli Ki Shadi

Free Download

ViewData, ViewBag and TempData in ASP.Net MVC

ViewBag

– ViewBag is used to send a small amount of data to the view.
– There may be some situation where you want to transfer some temporary data to view which is not included in the model object.
– The viewBag is a dynamic type property of ControllerBase class.
– It does not retain value when redirection occurs,it is available only for Current Request.
– ViewBag is a dynamic property and it makes use of the C# 4.0 dynamic features.
public class DemoController : Controller
{
IList CarList = new List() {
new Car(){ CarName=”i10″, CarColor=”Black”,CarMileage=18.2 },
new Car(){ CarName=”EON”, CarColor=”Silver”, CarMileage=18.2 },
new Car(){ CarName=”Swift”, CarColor=”Red”, CarMileage=18.2},
new Car(){ CarName=”Verna”, CarColor=”Black”, CarMileage=18.2},
new Car(){ CarName=”Ciaz”, CarColor=”Silver”, CarMileage=18.2}
};
public ActionResult Index()
{
ViewBag.TotalCar = CarList.Count();
return View();
}
}

ViewData

– ViewData is similar to ViewBag, It can be used to send data from controller to view.
– It is a dictionary , which possese key-value pairs, where each key must be string.
– Viewdata last long only for current http request.
public class DemoController : Controller
{
public ActionResult Index()
{
ViewData[“Simple”] = “This string is stored in viewData.”;
return View();
}
}
To get back value from viewData write below line in view.

@ViewData[“Simple”]

TempData

– TempData retain value across subsequent HTTP Request
– It can be use to maintain data between controller actions as well as redirects.
– It internally stores data in session but it get destroyed earliar than session.
In the below example, a string value is stored in the TempData object in JupiterController
and it is redirected to EarthController and finally it is displayed in View.
public class JupiterController : Controller
{
// GET: First
public ActionResult Index()
{
TempData[“Message”] = “Jupiter is largest planet in solar system”;
return new RedirectResult(@”~\Earth\”);
}
}
public class EarthController : Controller
{
// GET: Second
public ActionResult Index()
{
return View();
}
}
View of EarthController
<html>
<head>
<meta name=”viewport” content=”width=device-width”/>
<title>Solar System</title>
</head>
<body>
<div>
@TempData[“Message”];
</div>
</body>
</html>

Saturday, January 14

How to Get AdSnse Account Approved for Blogspot with Little Trick

Get Google Adsense Approval within 3 days – Top 12 Working Strategies

Google AdSense! One of the most easiest, trusted and professional way of earning money by showing your passion towards writing and sharing the knowledge. Google AdSense is trusted by many advertisers and publishers from the past few years, and usually they never accept anyone randomly who is trying to apply for an account. You need to show them the most professional approach of getting your account accepted, else Google will simply throw your application aside.

We all know that AdSense contextual ads are best-paying Ad program for Bloggers. Though, I have already shared my tutorial on: Create Adsense account but question remains the same: How to get Adsense account approval for BlogSpot bloggers, getting an AdSense approval is not that easy. Google AdSense have some strict account approval policies, and one of them is blog should be six months old. Though, it’s not always true, and if you have created a quality Website, you can get an approved AdSense account easily.
The major problem is for BlogSpot bloggers, for some reasons Google AdSense, doesn’t entertain BlogSpot bloggers. One of the most common reason BlogSpot bloggers get is Issue with page type.  One easy way to get AdSense account with a BlogSpot blog is grabbed a custom domain, create a professional Email address and apply for AdSense account. This works, in 70% of cases. But, in case if you don’t have money to spend on a domain, here is a free trick which will get you an AdSense account approval with co.cc domain.
how to get adsense account
There is a simple trick which you can use to get your AdSense account approved for Blogspot domain quickly.
If your BlogSpot account have sufficient number of post (minimum 20+) then it’s easy to get your AdSense account approved. If you have personal domain and host chances of AdSense approval are very high.
Now the question is:

How to get Adsense account approval for BlogSpot blog:

Even I got my AdSense account approved after almost 8 re-submission.


Get Google Adsense Approval within 3 days – Top 12 Working Strategies

Google AdSense! One of the most easiest, trusted and professional way of earning money by showing your passion towards writing and sharing the knowledge. Google AdSense is trusted by many advertisers and publishers from the past few years, and usually they never accept anyone randomly who is trying to apply for an account. You need to show them the most professional approach of getting your account accepted, else Google will simply throw your application aside.

Statistics say that Google AdSense accepts only 3 accounts of every 1000 applications they receive each day. If you are trying to get onto the account or has been rejected earlier, follow these simple guidelines to get your own AdSense account in just 3 simple days. Though these below tips won’t get you the account approved instantly, but will surely work if you try inheriting each step mentioned below. I’m sure it worked for 60% of people who commented here and mailed me from the past couple of years.

Get Google AdSense Approval Within 3 Days:

So before getting started, make sure you follow these guidelines without fail, else your application will be rejected without any further pending approval. Remember that everything which I mentioned below counts. Don’t compromise on number of posts, own domain, good design and other metrics, else the chances of rejection is higher at your end. So here we go, the 15 most important guidelines to follow before applying to Google AdSense.



Minimum Posts/Articles/Pages:

If you are using WordPress, make sure your website/blog has at least 40 quality articles which are not copied from anywhere else. Your content on the articles should be extremely rich and make sure you use relevant images where ever required. Try to include two lengthy articles of 2000 words each, which should be absolutely stunning while anyone reads them on your website. If you are using HTML website or any other non CMS version of blog, make sure you have atleast 50 pages on your website in form or articles or landing pages.
If you miss providing this any of the above information on your website, Google might reject your application saying Insufficient Content or Unacceptable Site Content. So make sure they see enough content on your website before applying the program. The more the content, the better chances of approval.

Prohibited Website Niches:

Statistics show that your account will go through a faster approval process if you have more quality articles on Health, Internet Marketing, Business, Law, Technology, Entrepreneurship, Travel, Lifestyle and Social Media. Google will take your application as a serious offense if your website contain any of the prohibited content mentioned in this link here.
Some studies have also proved that Google AdSense might reject your approval if your website is on event blogging and micro niche blogging. In this particular blogging, you limit your blog content to only one particular subject and create a spam domain around it to rank higher. Eg: www.mayweathervspacquiaomatchonline.com (Mayweather vs Pacquiao Match Online). In some cases, if you have observed Google Ads in these of websites, probably they have applied the account through an another account and placed the ads in this event niche blogging to earn quick money.

No Third Party Ads or Programs:

Before applying to AdSense, make sure you don’t allow or place any other third party banner ad code on your website. Google (employees) will strictly look into your website manually and they hate seeing some third party ads installed in your website. Stay away from Infolinks, Chitika, Yahoo Ads or any other third party network to get the first impression clean on your website. Make sure you put only the fresh content and some regular widgets on the website.
Also, stay away from affiliate links such as hosting programs, Amazon affiliates, Clickbank or anyother until your account is approved.

Website Design and User Experience:

Google always want their users to get the best experience while browsing through any website they refer. Maintaining a clean design with good navigation and user experience will boost your chances of getting AdSense approved in the first attempt itself. This is one of the major guidelines where lot of people miss the basics. Google believes that if you maintain professional color scheme on your website, the user might be willing to come back and click on the relevant ads which are displayed under your content.
So make sure you maintain a neat and clean design before applying to AdSense. I would recommend you to buy one professional template anywhere and get it installed on your website without effecting the loading speed or easy navigation.

Google Analytics Code:

Adding Google Analytics code on your website is a trusted factor for the approval. Adding Analytics onto your website show that you are actively tracking your visitors and is much serious about the statistics of your users who visit your website. If you haven’t created one, click here to register the program. Once registered, get your tracking code by creating new account under the accounts tab and enter your website name, URL and other required details. Place the code on each page of your website to track the data instantly.

Google/Bing Webmasters Verification Page:

Just like Google Analytics, you need to even verify with Google Webmaster program, which has the complete access to your website in search perspective. With Google Webmaster Tools, you can track your website critical errors and fix them on a daily basis. Click here to register and click on “Add a Site” to enter your website URL. Verify your website ownership through any of the recommended method and complete the process to keep your account functioning actively.
Also, adding the Bing Webmaster Tools to your website will add more credibility to your domain that you are serious about the website search visibility. Though this guideline is pretty easy to perform, many people will get comfortable without knowing the importance of installing these tools.
Adding these two verifications on your website code or server will show good results on search visibility as well.

XML Sitemap Page: 

Creating a sitemap doesn’t take too much of your time. If you are using WordPress, I recommend Google XML Sitemaps By Arne Brachhold. And if you are using any other platform, I recommend you to checkout XML-Sitemaps website for more info. Installing a sitemap on your website can help search engine bots to index your website faster, which is again a trust factor to bots about the website trustworthiness.

Robots.txt

Creating Robots.txt file on your website will get rid of indexing unwanted junk onto Google. I have written a detailed post few days back on how to write perfect robots.txt for your website. Else you can also check SEOSiren.com own robots.txt file and simply copy it to your WordPress website. I have restricted all the unwanted data indexation to search engines, which adds a lot of value to your SEO efforts of ranking the pages higher on Google. Plus, robots.txt file is another great feature to add it your website as a trust factor.

Alexa Rank:

Google AdSense considering the Alexa rank has always been a controversy, as many people disagree that Google doesn’t care about your global rankings. Trust me, I strongly believe that this is one of the most important checklist any manual operator checks before even opening your website statistics. How can anyone quickly judge about a website performance? The answer is simple, and its Alexa ranking. So make sure you install the Alexa toolbar and read my eBook on how to boost Alexa ranking within 30days.
Note: Before applying to AdSense, make sure your website global Alexa ranking is less than 400K for faster approval process. Usually the website above this rank is considered to be new and underestimated that no much data is seen on them.

Important Pages:

Google wants to know your identity before you signup to their AdSense program. So make sure your create the following pages on your website as soon as possible.
  1. Privacy Policy
  2. Disclaimer Policy
  3. Terms of Usage
  4. Contact Us
  5. About Us (Write your name and address through which you applied the AdSense account)
In the about us section, clearly mention who you are, and why is this website made for, what is the benefit people get out of your website. The more clear, the better the chances of your approval. Keep your spelling mistakes, grammar and punctuation clear when you do this.

Custom Domain and Email ID:

A lot of people get create websites through blogspot and free WordPress platforms to apply AdSense. Note that AdSense team will take a custom domain more seriously rather than the free domain name. Investing 2$ on a domain name is not a big deal when you have health chances of getting approval with other factors like mentioned above. So don’t give yourself a second chance to apply the AdSense program and get your own domain as early as possible.
Once you have your own domain, create an email ID with your name (name@website.com) to apply the AdSense program. Eg: satish@seosiren.com will get more attention compared to satishseosiren@gmail.com. Note that your free website programs give you the privilege or adding your custom domains without paying any additional fee.

Decent Traffic: 

Though a lot of portals, forums mention that Google AdSense doesn’t require any certain amount of pageviews to approve your account, I still feel and experienced the treatment if you have a decent traffic. Let your blog age a few weeks (atleast 2 months) before you rush to apply the AdSense program. I would always recommend you to stay until your website get a minimum of 50+ visitors per day. If your website is not getting enough traffic, the chances of rejection is much higher when compared to other guidelines.
Once your website is ready with all these above guidelines, click here to apply to Adsense, and make sure you have gone through the Google AdSense TOC for more information on the program.
Leave your comments to check if your doing good with the process. And if your AdSense was rejected despite of following all these above mentioned guidelines, shoot me a mail to satish@seosiren.com and I will help you out with a free AdSense consultation. Stay tuned to SEOSiren for more such interesting topics!
Also, I have made a step by step video guide on how to apply Adsense if you are looking for more information. Check out the below video and let us know if you still have trouble in getting your account approved.

 

How To Create and Setup a Google Account In 7 Steps

Google Account

Creating a Google Account

Introduction

Creating a Google account is fairly simple. You'll need to provide some basic information, like your name, age, and location. Once you create and verify your account, you'll be able to use Gmail, Google Docs, Google Calendar, Google+, and many other services.
In this lesson, we'll show you how to create an account.

Creating an account

In order to create a Google account, you'll need to enter some information, like your name, birth date, and location. Creating a Google account will automatically create a Gmail email address and a Google+ profile.
If you have a Gmail address, you already have a Google account so you won't need to create an account. You can simply sign in to Google using your Gmail information.

To create a Google account:

 Go to www.google.com. Locate and select the Sign in button in the top-right corner of the page.

Click Create an account.

The signup form will appear. Follow the directions by entering the required information, such as your name, birth date, and gender.

Review Google's Terms of Service and Privacy Policy, click the checkbox, then click Next step.

The Create your profile page will appear. Click Add a photo if you want to add a photo to your Google+ profile. If you don't want to set a profile photo at this time, click Next step.

Your account will be created, and the Google welcome page will appear.

 

Create a Cross-platform App with Visual Studio

Introduction

Did you know that you can write mobile applications with great user interfaces that are cross-platform — supporting Android, iOS, and Microsoft phones and tablets — with just HTML, JavaScript, and CSS?
That's right, times are changing and it is easier than ever with Visual Studio Community Edition's Ionic templates which are free. Believe it or not, Visual Studio is ahead of the game for Ionic development under Windows providing a first-class IDE with excellent stock projects that run on mobile devices out-of-the-box.

Code Samples

Below are the complete code samples of the Ionic project files modified in the tutorial.

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <script src="js/platformOverrides.js"></script>

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
  </head>
  <body ng-app="starter">

    <ion-pane>
      <ion-header-bar class="bar-positive" align-title="center">
        <h1 class="title">First Ionic App</h1>
      </ion-header-bar>
      <ion-content ng-controller="HomeCtr">

          <br /><br />

          <div class="row">
              <div class="col">
                  <button class="button button-royal icon-left ion-home" ng-click="message='Home clicked!'">Home</button>
              </div>
              <div class="col">
                  <button class="button button-calm icon-left ion-edit" ng-click="message='Edit clicked!'">Edit</button>
              </div>
          </div>

          <div class="row">
              <div class="col">
                  <button class="button button-balanced icon-left ion-ios-copy-outline" ng-click="message='Copy clicked!'">Copy</button>
              </div>
              <div class="col">
                  <button class="button button-assertive icon-left ion-search" ng-click="message='Search clicked!'">Search</button>
              </div>
          </div>

          <br />
          <br />

          <h2>{{message}}</h2>

      </ion-content>
    </ion-pane>
  </body>
</html>
 
app.js

angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(cordova.platformId === 'ios' && window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });

}).controller('HomeCtr', function ($scope) {

    $scope.message = "Okay are you going to click a button?";

});
 

Conclusion

I hope you've found this tutorial for developing cross-platform mobile apps helpful. Best wishes for your mobile app development projects.
 

 


how to connect database with mysql, MySQLi , pdo – php

how to connect database with mysql, MySQLi , pdo in php

Mysql database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysql_connect($database_host, $database_user, $database_pass);

// check database connection
if(! $database_conn )
{
    // error in database connection
    die('Could not connect to database : ' . mysql_error());
}
// connected to database
echo 'Connected successfully with database';

// close connection with Mysql database
mysql_close($database_conn); 


MySQLi Object-Oriented database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = new mysqli($database_host, $database_user, $database_pass);

// check database connection
if ($database_conn->connect_error)
{  
    // error in database connection
    die("Could not connect to database : " . $database_conn->connect_error);
}

// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi database
$database_conn->close();

MySQLi Procedural database connection

$database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password

// connect with database
$database_conn = mysqli_connect($database_host, $database_user, $database_pass);

// check database connection
if (!$database_conn)
{
    // error in database connection
    die("Could not connect to database : " . mysqli_connect_error());
}

// connected to database
echo 'Connected successfully with database';

// close connection with MySQLi Procedural
mysqli_close($database_conn);

PDO database connection

$database_host = 'localhost'; // database host name   
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password
$database_name = 'your_database_name'; // database name

try
{
    $database_conn = new PDO("mysql:host=$database_host;dbname=$database_name", $database_user, $database_pass);
    // if using port then use port id in PDO 
    //$database_conn = new PDO('mysql:host=$database_host;port=5432;dbname=$database_name', $database_user, $database_pass);
    
    // exception for PDO connection error
    $database_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // connected to database
    echo 'Connected successfully with database';
}
catch(PDOException $exception)
{
    // error in database connection
    echo "Could not connect to database : " . $exception->getMessage(); // exception
}

// close connection with PDO
$database_conn = null;


PHP – send email with attachment file

how to send email with attachment file in PHP

In this post we will show you how to send email with attachment in php. by using this following code is used for send email with attachment in php. following code will sending pdf file in email.

$file_name = "example.pdf"; // attachment file name
$path = "folder_name"; // path of attachment file
$user_name = "user name"; // user name
$mail_to = "onlinecode@email.com"; // to eamil
$email_subject = "Notification of attachment for user"; // subject of eamil
$body_text = "Hello ".$user_name.",\nThis demo message with file attachment. You will be notified when their review has been completed.\n Regard \n onlinecode Team";

$attachment_file = $path . "/" . $file_name; // path of file
$attachment_file_size = filesize($attachment_file);
$email_handle = fopen($attachment_file, "r");
$content = fread($email_handle, $attachment_file_size);
fclose($email_handle);// file close of email handle
$content = chunk_split(base64_encode($content));
$time_separator = md5(time());// a random hash will be necessary to send mixed content

// carriage return type (we use a PHP end of line constant)
$email_eol = PHP_EOL;
$body_message = $body_text;
// main header (multipart mandatory)
$email_headers = "From: onlinecode.org Team &lt;onlinecode@email.co&gt;" . $email_eol;
// sender eamil detail
$email_headers .= "MIME-Version: 1.0" . $email_eol;//MIME-Version
$email_headers .= "Content-Type: multipart/mixed; boundary=\"" . $time_separator . "\"" . $email_eol;//Content-Type
$email_headers .= "Content-Transfer-Encoding: 7bit" . $email_eol;//Content-Transfer-Encoding
$email_headers .= "This is a MIME encoded message." . $email_eol;

// eamil message
$email_headers .= "--" . $time_separator . $email_eol;
$email_headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $email_eol;
$email_headers .= "Content-Transfer-Encoding: 8bit" . $email_eol;
$email_headers .= $body_message . $email_eol;

// attachment
$email_headers .= "--" . $time_separator . $email_eol;
$email_headers .= "Content-Type: application/octet-stream; name=\"" . $file_name . "\"" . $email_eol;
$email_headers .= "Content-Transfer-Encoding: base64" . $email_eol;
$email_headers .= "Content-Disposition: attachment" . $email_eol;
$email_headers .= $content . $email_eol;
$email_headers .= "--" . $time_separator . "--";
mail($mail_to, $email_subject, ", $email_headers); //SEND Mail TO USER

 

insert category programmatically in magento

In this post we’ll show you how to magento insert category programmatically using magento. By using following code we can insert category programmatically and this code also work in exteranl magen to file.

$parentId = '2'; // prenet catagory
try{
    $category = Mage::getModel('catalog/category');
    $category->setName('category-name'); // category name
    //$category->setUrlKey('your-category-url-key'); // url key
    $category->setIsActive(1); // is active
    $category->setDisplayMode('PRODUCTS');
    $category->setIsAnchor(1); //for active anchor
    $category->setStoreId(Mage::app()->getStore()->getId());
    $_parent_category = Mage::getModel('catalog/category')->load($parentId);
    $category->setPath($_parent_category->getPath());
    $cat_data= $category->save(); // insert catagory
    //echo $cat_data->getEntityId();// print catagory id
}
catch(Exception $e)
{
    print_r($e);//Exception in insert catagory
}

Friday, January 13

customer registration programmatically in Magento code from an external php file

In this post we’ll show you how to customer registration programmatically in magento using with exteranl php file. By using following code we can register user and create seeeion on user or customer.
  • This post is use for register user or customer registration programmatically in Magento.
  • first we create user ,if user is not exist then insert data into database then we will go for login to user programmatically.
  • add you detail in variable and enjoy the code.       
set_time_limit(0);
ini_set('memory_limit', '1024M');
include_once "app/Mage.php";  // Mage file include
include_once "downloader/Maged/Controller.php"; // Controller file include
error_reporting(E_ALL | E_STRICT);

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

Mage::getSingleton('core/session', array('name' => 'frontend'));

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

Customer / user registration programmatically in Magento

$website_Id = Mage::app()->getWebsite()->getId();
$store_detail = Mage::app()->getStore();

$setFirstname = "Firstname"; // add  First name
$setLastname = "setLastname"; // add Last name
$setEmail = "Ttest123@gm.co"; // add  Email id
$setPassword = "password@789"; // add  password
/*$setPostcode = "989898"; // add  Post code
$setCity = "Sydney "; // add  city of user
$setRegion = "New South Wales";
$setTelephone = "99999999999";
$setFax = "123456";
$setCompany = "Australia";
$setStreet = "in Australia some place";*/
$customer = Mage::getModel("customer/customer");
$customer ->setWebsiteId($website_Id)
->setStore($store_detail)
->setFirstname($setFirstname)
->setLastname($setLastname)
->setEmail($setEmail)
->setPassword($setPassword);
try{
    $results = $customer->save();   
    $getEntityId = $results->getEntityId(); // get user id
}
catch (Exception $e) {
    // bug or user is exist
    echo $e->getMessage(); // print Exception Message
}

Mage::getSingleton('core/session', array('name' => 'frontend'));

$sessionCustomer = Mage::getSingleton("customer/session");
$red_url = "http://www.onlinecode.org/";
if($sessionCustomer->isLoggedIn()) {
    header('Location: '. $red_url);
    break;
}
else{
    //echo $setEmail." ".$setPassword;
    loginUser($setEmail,$setPassword);
    //header('Location: '. $red_url);
    //break;
}
// function for login user programmatically
function loginUser($email,$password){
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend"));
    $website_Id = Mage::app()->getWebsite()->getId();
    $store_detail = Mage::app()->getStore();
    $customer_detail = Mage::getModel("customer/customer");
    $customer_detail->website_id = $website_Id;
    $customer_detail->setStore($store_detail);
    try
    {
        $customer_detail->loadByEmail($email);
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer_detail);
        $session->login($email,$password);
    }
    catch(Exception $e)
    {
        echo $e->getMessage();// print Exception Message
    }
}

php json encode and decode example

<?php
echo "<br><h1>JSON Encode_decode with php</h1></br>";
echo"JSON_DECODE<br/>--------------------------------------------";
echo"<br/>";
$json = '{"a":1,"b":2,"c":3}';//Example 1
$j=json_decode($json);

echo "Value a= ". $j->{'a'};
echo "Value b= ". $j->{'b'};
echo "Value c= ". $j->{'c'};

echo"<br/>--------------------------------------------";
echo"<br/>";
echo"JSON_ENCODE<br/>--------------------------------------------";
echo"<br/>";

$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);//Example 2
echo json_encode($arr);
echo"<br/>";
// Output {"a":1,"b":2,"c":3,"d":4,"e":5}


$arr = array ( 1, 2, 3, 4, 5 ); //Example 3
echo json_encode($arr);
echo"<br/>";
// Output [1,2,3,4,5]


$arr['x'] = 10;  //Example 4
echo json_encode($arr);
echo"<br/>";
// Output {"0":1,"1":2,"2":3,"3":4,"4":5,"x":10}


echo json_encode(54321); //Example 5
echo"<br/>";
// Output 54321
echo"<br/>--------------------------------------------";

//Example 1

echo "<br/>Example #1 : The following example shows how to convert an ARRAY INTO JSON WITH PHP
<br/><br/><br/>";

$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
echo "<br/>";

//Example 2


echo "<br/>Example #2 : The following example shows HOW THE PHP OBJECTS CAN BE CONVERTED INTO JSON
<br/><br/><br/>";

class Emp {
public $name = "";
public $hobbies = "";

}
$e = new Emp();
$e->name = "sachin";
$e->hobbies = "sports";

echo json_encode($e);

//Example 3

echo "<br/>Example #3 : The following example shows HOW PHP CAN BE USED TO DECODE JSON OBJECTS
<br/><br/><br/>";

$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
echo "<pre>".var_dump(json_decode($json))."</pre>";
echo "<pre>".var_dump(json_decode($json, true))."</pre>";
echo "<br/>";

//Example 4

echo "<br/>Example #3 : The following example shows HOW PHP CAN BE USED TO DECODE JSON OBJECTS
<br/><br/><br/>";

$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
echo "<pre>".var_dump(json_decode($json))."</pre>";
echo "<pre>".var_dump(json_decode($json, true))."</pre>";
echo "<br/>";


?>

get longitude and latitude from an address with PHP and Google Maps API :Example

<?php
$url = "http://maps.google.com/maps/api/geocode/json?address=india+gujrat+rajkot&sensor=false&region=India";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);

$response = json_decode($response);
echo "<pre>";
print_r($response);
echo "<pre>";

echo "Latitude : ".$lat = $response->results[0]->geometry->location->lat;
echo "<br/>";
echo "Longitude :".$long = $response->results[0]->geometry->location->lng; 
?>

Example 2:

<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://completion.amazon.com/search/complete?search-alias=aps&client=amazon-search-ui&mkt=1&q=google");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
echo curl_getinfo($curl, CURLINFO_HTTP_CODE); // code here
curl_close($curl);

die();
echo "<pre>";
print_r(json_decode($result));//return amazone autocomplete suggestion
echo "</pre>";
?>

Get City Country By IP Address in PHP

index.php

<?php
$ip_addressget=$_SERVER['REMOTE_ADDR'];

/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_addressget;

$addrDetailsArr = unserialize(file_get_contents($geopluginURL));

/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];

/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];

/*Comment out these line to see all the posible details*/
/*echo '<pre>';
print_r($addrDetailsArr);
die();*/

if(!$city){
   $city='Not Define';
}if(!$country){
   $country='Not Define';
}
echo '<strong>IP Address is</strong>:- '.$ip_address.'<br/>';
echo '<strong>City is </strong>:- '.$city.'<br/>';
echo '<strong>Country is </strong>:- '.$country.'<br/>';
?>

PHP String Functions with Example

<?php
//Get The Length of a String :Example
echo strlen("Welcome WEB!"); // outputs 10

//Count The Number of Words in a String :Example
echo str_word_count("Welcome WEB!"); // outputs 2

//Reverse a String :Example
echo strrev("Hello world!1"); // outputs 1!dlrow olleH

//Search For a Specific Text Within a String :Example
 echo strpos("Hello world!", "world"); // outputs 6

//Replace Text Within a String :Example
echo str_replace("world", "King", "Hello world!"); // outputs Hello King!


//PHP Strlen() Function :Example

$name="king";
if ( strlen( $name ) != 5 ) 
{
    echo "Correct input.";
}
else
{
    echo "incorrect input";
}

//PHP chr() FUNCTION :Example
echo chr(35); //#

//PHP strcmp()FUNCTION :Example
<?php echo strcmp("Hello world!","Hello world!"); ?> //Returns 0

//PHP explode()FUNCTION :Example

 $str = "Hello world. It's a beautiful day.";
 print_r (explode(" ",$str));
/* Output :
Array
 (
 [0] => Hello
 [1] => world.
 [2] => It's
 [3] => a
 [4] => beautiful
 [5] => day.
 )
*/

//PHP implode()FUNCTION :Example

$arr = array('Hello','World!','Beautiful','Day!');
 echo implode(" ",$arr);
/*
Output:
Hello World! Beautiful Day!
*/

//PHP str_replace()FUNCTION :Example

 $phrase  = "You should eat fruits, vegetables, and fiber every day.";
 $healthy = array("fruits", "vegetables", "fiber");
 $yummy   = array("pizza", "beer", "ice cream");
 $newphrase = str_replace($healthy, $yummy, $phrase);

/*
Output :
You should eat pizza, beer, and ice cream every day
*/

//PHP substr()FUNCTION :Example

 echo substr("Hello world",6);  //Returns world
 echo substr("Hello world",6,4); // Returns worl
 echo substr("Hello world", -1); // Returns  d
 echo substr("Hello world", -3, -1); // Returns rl

?>

PHP Connect to My SQL Database

<?php
$ng_username = "your_user_name";//localhost
$ng_password = "your_user_password";//password
$ng_hostname = "localhost/servername"; //127.0.0.1

//The connection to the database using PHP
$dbhandle = mysql_connect($ng_hostname, $ng_username, $ng_password)
  //or die(mysql_error());//Show Error generated.
  or die("in database connection details : Does not connect Mysql Databased ");
echo "database connection details : Your Database Connected to MySQL succesfully<br>";
?>


//Other way to select a database to work with


<?php
$selected = mysql_select_db("DatabaseName",$dbhandle_varname)or die("details of connect database - can not connect your database");
?>

Second way to external php to MYSQL connect databased- config.php
----------

<?php
$username_ng = "root";//localhost
$password_ng = "ng4free";//password
$hostname_ng = "localhost or ip"; //127.0.0.1

//connection to the database
$dbhandle = mysql_connect($hostname_ng, $username_ng, $password_ng)
  or die("Disconnect your databased in MYSQL/ Unable to connect to MySQL : details");
echo "You are Connected to MySQL Databased<br>";

$selected_databased = mysql_select_db("users",$dbhandle)or die("Databased Details : does not/Could not select users");

?>

Full Example : How to connect to MySQL database using PHP

<?php
$user_username = "Default (root)Your username or root";
$user_password = "Host (Password)genrated password";
$user_hostname = "localhost / server host";

//The above us to connection to the database
$dbhandle = mysql_connect($user_hostname, $user_username, $user_password)
 or die("Error : Unable to connect to MySQL");
echo "PHP to connect MySQL Databased success. <br>";

//The Script is select a database to work with
$selected = mysql_select_db("test",$dbhandle)
  or die("Could not select test");

//IT's is query execute the SQL query(handle) and return records
$result_data = mysql_query("SELECT your_id, modelname,year FROM cars_company");

//Loop through fetch tha data from the database Using PHP Script
while ($row = mysql_fetch_array($result_data)) {
   echo "ID:".$row{'your_id'}." Name:".$row{'modelname'}."Year: ". //Print display the results
   $row{'year'}."<br>";
}
//Dtabased close the connection
mysql_close($dbhandle);//connection close
?>

Now Go To Localhost/phpmyadmin and to create 'cars_company' database on your MySQL server you should run the following script:

CREATE DATABASE `users`;
USE `cars_company`;
CREATE TABLE `cars_company` (
   `your_id` int UNIQUE NOT NULL,
   `modelname` varchar(40),
   `year` varchar(50),
   PRIMARY KEY(your_id)
);

INSERT INTO cars_company VALUES(1,'ngcomapny','2000');
INSERT INTO cars_company VALUES(2,'ng4free','2004');
INSERT INTO cars_company VALUES(3,'ngdemo','2001');

Wednesday, January 11

Visual Studio 2013 Tips and Tricks

You can use below tips and trick in visual studio to enhance the speed of coding and development.
(1) Matching brace/comment/region/quote
“Ctrl+]” can be used to the match brace, region, quote. It can also be used to the match comment, region or quote depending on where is the cursor now.
(2) Create Property By Shortcut
Creating Properties are very common to get and/or set values. For writing Property, you do not need to write it completely. just type PROP and then press TAB key twice.
(3) Vertical block selection.
Select Alt key and then select the area you want with your mouse.

(4) Auto Complete
Using IntelliSense in Visual Studio you can complete method, variable, class, object, property etc. by just writing its initial. Use Ctrl + Space or Alt + Right Arrow.
(5) Bookmark
Using Bookmark you can navigate to code in visual studio.
Create/Remove Bookmark – Ctrl+K, Ctrl+K
Move to next bookmark – Ctrl+K, Ctrl+N
Move to previous bookmark – Ctrl+K, Ctrl+P
Clear all bookmarks – Ctrl+K, Ctrl+L

(6) Build and Debug

Build – Ctrl+Shift+B
Run – Ctrl+F5
Debug – F5
Cycle through build errors – F8

(7) Move Code Up or Down
If you want to move a line up then just keep the cursor on that line and press “Alt + Up Arrow key” similar to this if you want to move the line down then just keep the cursor on that line and press “Alt + Down Arrow key”.

(8) Comment Code block
Comments are used for documentation purpose or temporarily disable the code. You can comment block of code by selecting that portion and then press Ctrl-K + C. To uncomment code select code block and press Ctrl-K + U.

(9) Switch between Currently open tabs.
You can open lastly visited tab in visual studio by pressing Ctrl + Tab and for opposite direction Ctrl + Shift + Tab
So, these are some commonly used shortcuts which will save your time.

OOPS Concepts, Features & Explanation with Example in C#.Net

– OOPS = Object Oriented Programming.
– OOPS is a programming technique which provides an efficient way to manage Object and its behaviour across a system.
– OOPS provides a way to show/hide relevant data.
– OOPS provides an efficient way for code reusability.

Here I will explain you important concepts of OOPs.

(1) Class

– The class can be considered as a blueprint for an object.
– A class is a collection of object.
– It is compulsory to create a class for representation of data.
– Class do not occupy memory space, so it is a merely logical representation of data.

The syntax for declaring a class.

public class College
{
//your code goes here.
}

(2) Object

– The object is variable of type Class.
– Object possess property and behaviour.
– As a class do not occupy any memory, so to work with real-time data representation you need to make an object of the class.

Syntax
– Here is the syntax to create an object(we just created above).

College objCollege = new College();

(3) Encapsulation

– Encapsulation is the process of keeping item into one logical unit.
– Encapsulation is a technique used to protect the information in an object from another object.
– The concept of data hiding or information hiding can be achieved by encapsulation.
– In c#,Encapsulation is implemented using the access modifier keywords. C# provides 5 types of access modifier,
which are listed below.
(i) Public : Public members are accessible by any other code in the same  assembly or another assembly that reference it.
(ii)Private : Private member can only be accessed by code in the same class.
(iii)Protected: Protected member can only be accessed by code in the same class or in a derived class.
(iv)Internal : Internal member can be accessed by any code in the same assembly, but not from another assembly.
(v) Protected Internal : Protected Internal member can be accessed by any code in the same assembly, or by any derived class in another assembly.

(4) Polymorphism

– Polymorphism is an ability to take more than one form in different case/scenario.
– It can make different logical units but with the same name. Its behaviour is executed based on input or the way it is called.

class PolymorphismExample
{
public void Add(int p_Value1, int p_Value2)
{
Console.WriteLine(“Result ={0}”, p_Value1 + p_Value2); // This will perform addition of p_Value1 and p_Value2
}

public void Add(string p_Value1, string p_Value2)
{
Console.WriteLine(“Result ={0}”, p_Value1 + p_Value2); // This will perform concatenation of p_Value1 and p_Value2
}
}

(5) Inheritance

– Inheritance provides a way to inherit member of another class.
– It Provides a way to reuse code which is already written.

class InheritanceExample
{
public abstract class AllCar
{
public abstract string GetCarName();
}

public class HondaSeries : AllCar
{
//this method name matches with same signature/parameters in AllCar class
public override string GetCarName()
{
return “Car Name is Honda City”;
}
}

public static void Main(string[] args)
{
AllCar objAllCar = new HondaSeries();
Console.WriteLine(objAllCar.GetCarName());
Console.Read();
}
}

Wednesday, January 4

How to convert an array to object in PHP?

How to convert an array to object in PHP?
This post will show you how to convert convert an array to object with different conditions of array in PHP.
Convert array to object using json.


The Best, quick, dirty, very effective and easy way (also my personal recommendations) to convert array to objects using json_encode and json_decode, it will turn the entire array (also including sub elements of array) into an object.

// Convert array into an object
$object = json_decode(json_encode($array));

var_dump ($object); // print object value with var_dump   


Convert associative array in to object

$array = Array ( 'keys' => "status value" );
// convert array in to object
$object = (object) $array;

var_dump ($object); // print object value with var_dump

var_dump($object->keys); // echo object value using key

Convert mulch-dimensional array( with same associative array) to object with simple way


$array = array (
    "0" => Array( "status_key" => "test value of keys 0" ),
    "1" => Array( "status_key" => "test value of keys 1" ),
    "2" => Array( "status_key" => "test value of keys 2" )
);

simple way convert array in to object

// convert array in to object
$object = (object) $array;
var_dump ($object); // print object value with var_dump

This is another way to convert array to object with foreach loop

$object = new stdClass();

foreach ($array as $keys => $value ) {
    $object->{$keys} = $value;
}
var_dump ($object); // print object value with var_dump

In this mulch-dimensional array we will convert into an object.

$array = array (
    "test array",
    array( "keys test 1 value" ,"keys test 2 value" ,"keys test 3 value" ),
    array( "keys test 1 value" ,"keys test 2 value" ,"keys test 3 value" ),
    array( "keys test 1 value" ,"keys test 2 value" ,"keys test 3 value" ),
    array( "keys test 1 value" ,"keys test 2 value" ,"keys test 3 value" ),
);

$object = new ArrayObject($array);
var_dump ($object); // print object value with var_dump

foreach ($object as $keys => $val){
    if (is_array( $val )) {
        foreach($val as $sub_key => $sub_val) {
           echo $sub_key . ' => ' . $sub_val."<br>";
        }
    }
    else
    {
           echo $val."<br>";
    }
}

Convert array to object using function (with same associative array)

function arrat_to_object($array) {
    $objects = new stdClass();
    foreach ($array as $keys => $value) {
        if (is_array($value)) {
            $value = arrat_to_object($value);
        }
        $objects->$keys = $value;
    }
    return $objects;
}


$object = arrat_to_object($array); // pass array
var_dump ($object); // print object value with var_dump

Convert Manually array in to an object

$object = object; // assign array
foreach ($array as $keys => $values) {
    $object->{$keys} = $values;
}
var_dump ($object); // print object value with var_dump 


 

login customer programmatically – Magento

Magento – How to login customer programmatically

This post show login customer programmatically in Magento. In this given code will allow to login user/customer to login if they are not logion already. If user is not login then this code create session and allow and set seesion and allow login in magento website to user programmatically.

Y2meta free Download Youtube videos in MP3, MP4, WEBM, M4A formats - 2022 - https://infinityknow.com/y2meta/

Top 10 Profile BackLink is bellow...... 



function user_login( $user_email , $user_password ) {
    umask(0);
    ob_start();
    session_start();
    Mage::app('default');
    Mage::getSingleton("core/session", array("name" => "frontend")); // get Singleton of session
    $website_Id   = Mage::app()->getWebsite()->getId(); // get id of store or website
    $store_detail = Mage::app()->getStore();
    $uses_detail = Mage::getModel("customer/customer");
    $uses_detail->website_id = $website_Id;
    $uses_detail->setStore( $store_detail );
    try
    {
        $uses_detail->loadByEmail( $user_email );
        $session = Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($uses_detail);
        $session->login( $user_email , $user_password );
    }
    catch(Exception $exception)
    {
        echo $exception->getMessage(); // print Exception Message
    }
}

// check user is login or not
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{
    $user_email = "example@mail.com"; // user email id
    $user_password = "add magento login password";
    user_login( $user_email , $user_password );   
}
else
{
    echo "user is already login";
}

customer details – Get logged in customer details – Magento

Magento – How to Get Logged In customer details – Full Name, First Name, Last Name and Email Address

This post is use for get detail of Logged In customer details in Magento. In this post we check Customer is login or not, if Customer is login then we call function get_customer_detail(), It will tack all detail of Logged In Customer.

// function to get user detail
function get_customer_detail()
{
    // get current user detail
    $_customer = Mage::getSingleton('customer/session')->get_customer();
    // remove comments for show all detail of Customer
    // echo "</pre>
    // print_r($_customer);
    // echo "</pre>";
    // basic detail of customer
    echo $_customer->getPrefix();
    echo $_customer->getName(); // Full Name
    echo $_customer->getFirstname(); // First Name
    echo $_customer->getMiddlename(); // Middle Name
    echo $_customer->getLastname(); // Last Name
    echo $_customer->getSuffix();
    // other customer details
    echo $_customer->getWebsiteId(); // get ID of website/store
    echo $_customer->getEntityId(); // get Entity Id
    echo $_customer->getEntityTypeId(); // get Entity Type Id
    echo $_customer->getAttributeSetId(); // get Attribute Set Id
    echo $_customer->getEmail(); // get customer email Id
    echo $_customer->getGroupId(); // get customer Group Id
    echo $_customer->getStoreId(); // get customer Store Id
    echo $_customer->getCreatedAt(); // get Created date(yyyy-mm-dd hh:mm:ss)
    echo $_customer->getUpdatedAt(); // get getUpdated date(yyyy-mm-dd hh:mm:ss)
    echo $_customer->getIsActive(); // customer is active 1 or 0(not active)
    echo $_customer->getDisableAutoGroupChange();
    echo $_customer->getTaxvat();
    echo $_customer->getPasswordHash();
    echo $_customer->getCreatedIn(); // get Created In
    echo $_customer->getGender(); // get customer Gender
    echo $_customer->getDefaultBilling(); // get Default Billing
    echo $_customer->getDefaultShipping(); // get Default Shipping
    echo $_customer->getDob(); // get customer Dob (yyyy-mm-dd hh:mm:ss)
    echo $_customer->getTaxClassId(); // get TaxClass Id
}

// check user is login or not
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{
get_customer_detail();
}
else
{
echo "user is already login";
}

 

MySQL Select Query in php to select the records

MySQL Select Query is used to select the records from MySQL database tables in php

how to use MySQL Select Query is used to select the records from MySQL database tables using php.

PHP Select Data From MySQL(MySQL Select Query)

  PHP Select Data From MySQL

database name :: onlinecode_db
table name :: user_table
+----+------------+-----------+-----------------------------+
| id | first_name | last_name | user_email                  | // column name
+-----------+------------+-----------+----------------------+
| 1  | Peter      | Kong      | peterKong@mail.com          |
| 2  | John       | smith     | johnsmith@mail.com          |
| 3  | Shuvo      | Kent      | Shuvokent@mail.com          |
| 4  | John       | Habib     | johnHabib@mail.com          |
| 5  | Anthony    | Potter    | Anthonypott@mail.com        |
+-----------+------------+-----------+----------------------+

$database_host = 'localhost'; // database host name
 // if using port then add port $database_host = 'localhost:3036'; 
 $database_user = 'database_user'; // database user name
 $database_pass = 'database_password'; // database user password
 $database_name = 'onlinecode_db';  // database name
 
// connect with database
 $database_conn = mysql_connect($database_host, $database_user, $database_pass);
 
 // check database connection
 if(! $database_conn )
 {
     // error in database connection
     die('Could not connect to database : ' . mysql_error());
 }
 $sql_select_query = 'SELECT id,first_name,last_name,user_email FROM user_table';

 mysql_select_db($database_name);
 $sql_result = mysql_query( $sql_select_query, $database_conn );
 if(! $sql_result )
 {
     // error in sql query or Fetch data
     die('Could not get data: ' . mysql_error());
 }
 while($result = mysql_fetch_array($sql_result, MYSQL_ASSOC))
 {
     echo "User ID :{$result['id']}".
          "First Name : {$result['first_name']}".
          "Last Name : {$result['last_name']}".
          "Email Address : {$result['user_email']}";
 }
 echo "Get data successfully";
 
 // close connection with Mysql database
 mysql_close($database_conn);   


PHP Select Data From MySQLi Object-Oriented(MySQL Select Query)

 $database_host = 'localhost'; // database host name
// if using port then add port $database_host = 'localhost:3036'; 
$database_user = 'database_user'; // database user name
$database_pass = 'database_password'; // database user password
$database_name = 'onlinecode_db';  // database name

// connect with database
$database_conn = new mysqli($database_host, $database_user, $database_pass, $database_name);

// check database connection
if ($database_conn-&gt;connect_error)
{  
    // error in database connection
    die("Could not connect to database : " . $database_conn-&gt;connect_error);
}

$sql_select_query = 'SELECT id,first_name,last_name,user_email FROM user_table';
$sql_result =  $database_conn-&gt;query($sql_select_query);

if ($sql_result-&gt;num_rows &gt; 0) {
    // output data of each row
    while($result = $sql_result-&gt;fetch_assoc()) {
        echo "User ID :{$result['id']}".
         "First Name : {$result['first_name']}".
         "Last Name : {$result['last_name']}".
         "Email Address : {$result['user_email']}";        
    }
} else {
    echo "No data found";
}

// close connection with MySQLi database
$database_conn-&gt;close();

PHP Select Data From MySQLi Procedural(MySQL Select Query)

  $database_host = 'localhost'; // database host name
    // if using port then add port $database_host = 'localhost:3036'; 
    $database_user = 'database_user'; // database user name
    $database_pass = 'database_password'; // database user password
$database_name = 'onlinecode_db';  // database name

// connect with database
$database_conn = mysqli_connect($database_host, $database_user, $database_pass, $database_name);

// check database connection
if (!$database_conn)
{
    // error in database connection
    die("Could not connect to database : " . mysqli_connect_error());
}
    
$sql_select_query = 'SELECT id,first_name,last_name,user_email FROM user_table';   
$sql_result = mysqli_query($database_conn, $sql_select_query);

if (mysqli_num_rows($sql_result) &gt; 0)
{
    // output data of each row
    while($result = mysqli_fetch_assoc($sql_result)) {
        echo "User ID :{$result['id']}".
         "First Name : {$result['first_name']}".
         "Last Name : {$result['last_name']}".
         "Email Address : {$result['user_email']}";
    }
}
else
{
    echo "No data found";
}

// close connection with MySQLi Procedural
mysqli_close($database_conn);

PHP Select Data From PDO with Prepared Statements(MySQL Select Query)

 
 $database_host = 'localhost'; // database host name  
    $database_user = 'database_user'; // database user name
    $database_pass = 'database_password'; // database user password
$database_name = 'onlinecode_db'; // database name

try
{
    $database_conn = new PDO("mysql:host=$database_host;dbname=$database_name", $database_user, $database_pass);
    // if using port then use port id in PDO
    //$database_conn = new PDO('mysql:host=$database_host;port=5432;dbname=$database_name', $database_user, $database_pass);
   
    // exception for PDO connection error
    $database_conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   
    $sql_select_query = 'SELECT id,first_name,last_name,user_email FROM user_table';

    $database_conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $database_conn-&gt;prepare($sql_select_query);
    $stmt-&gt;execute(); // execute stmt

    // set the resulting(stmt result) array to associative
    $result = $stmt-&gt;setFetchMode(PDO::FETCH_ASSOC);
    foreach(new TableRows(new RecursiveArrayIterator($stmt-&gt;fetchAll())) as $key=&gt;$values)
    {
        echo $key." = ".$values;
    }
}
catch(PDOException $exception)
{
    // error in database connection
    echo "Could not connect to database : " . $exception-&gt;getMessage(); // exception
}

// close connection with PDO
$database_conn = null;


10 Best Chatting Apps In India

  The modern world is all about Internet. There was a time when people use to pay high telephone bills to stay in touch with their friends a...