Wasimxprt

PHP – Codeigniter – Wordpress – JavaScript – Developer

  • About
  • Portfolio
  • Contact me

RESTful Services API in PHP

Posted by wasimxprt on August 28, 2015
Posted in: PHP. Leave a comment

Representational state transfer (REST) is a software system for distributing the data to different kind of applications. The web service system produce status code response in JSON or XML format.

Database
Sample database users table columns user_id, user_fullname, user_email, user_password and user_status.

CREATE TABLE IF NOT EXISTS `users`
(
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_fullname` varchar(25) NOT NULL,
`user_email` varchar(50) NOT NULL,
`user_password` varchar(50) NOT NULL,
`user_status` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Continue Reading

Advertisements

Persistent Connections

Posted by wasimxprt on August 28, 2015
Posted in: MySQL. Leave a comment

Persistent Connections are meant to reduce the overhead of recreating connections to MySQL. When a persistent connection is created, it will stay open even after the script finishes running. Since Apache reuses it’s child processes, next time the process runs for a new script, it will reuse the same MySQL connection.

  • mysql_pconnect() in PHP

It sounds great in theory. But from my personal experience (and many others), this features turns out to be not worth the trouble. You can have serious problems with connection limits, memory issues and so on.

Apache runs extremely parallel, and creates many child processes. This is the main reason that persistent connections do not work very well in this environment. Before you consider using the mysql_pconnect() function, consult your system admin.

Prepared Statements

Posted by wasimxprt on August 28, 2015
Posted in: MySQL. Leave a comment

There are multiple benefits to using prepared statements, both for performance and security reasons.

Prepared Statements will filter the variables you bind to them by default, which is great for protecting your application against SQL injection attacks. You can of course filter your variables manually too, but those methods are more prone to human error and forgetfulness by the programmer. This is less of an issue when using some kind of framework or ORM.

Since our focus is on performance, I should also mention the benefits in that area. These benefits are more significant when the same query is being used multiple times in your application. You can assign different values to the same prepared statement, yet MySQL will only have to parse it once.

Also latest versions of MySQL transmits prepared statements in a native binary form, which are more efficient and can also help reduce network delays.

There was a time when many programmers used to avoid prepared statements on purpose, for a single important reason. They were not being cached by the MySQL query cache. But since sometime around version 5.1, query caching is supported too.

// create a prepared statement
if ($stmt = $mysqli->prepare("SELECT username FROM user WHERE state=?")) {
    // bind parameters
    $stmt->bind_param("s", $state);
    // execute
    $stmt->execute();
    // bind result variables
    $stmt->bind_result($username);
    // fetch value
    $stmt->fetch();
    printf("%s is from %s\n", $username, $state);
    $stmt->close();
}

Send e-Mail using PHPMailer and Gmail SMTP

Posted by wasimxprt on August 28, 2015
Posted in: PHP. Leave a comment

First of all download the PHPMailer library from this link : http://sourceforge.net/projects/phpmailer/

copy-paste the following script using your editor and save this file as “sendmail.php” and try it in your localhost server

<?php 



 require_once('class.phpmailer.php');
 
    $mail = new PHPMailer();
    $mail->CharSet =  "utf-8";
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->Username = "your_gmail@gmail.com";
    $mail->Password = "your_gmail_password";
    $mail->SMTPSecure = "ssl";  
    $mail->Host = "smtp.gmail.com";
    $mail->Port = "465";
 
    $mail->setFrom('your_gmail@gmail.com', 'your name');
    $mail->AddAddress('to_mail@mail.com', 'receivers name');
 
    $mail->Subject  =  'using PHPMailer';
    $mail->IsHTML(true);
    $mail->Body    = 'Hi there ,
                        <br />
                        this mail was sent using PHPMailer...
                        <br />
                        cheers... :)';
  
     if($mail->Send())
     {
        echo "Message was Successfully Send :)";
     }
     else
     {
        echo "Mail Error - >".$mail->ErrorInfo;
     }
  
?>

Continue Reading

PHP CRUD Application

Posted by wasimxprt on August 28, 2015
Posted in: PHP. Leave a comment

In this tutorial we are going to discuss about simple CRUD (Create , Read , Update , Delete) PHP operations , these are some of the basic things of PHP web application , Datas are insert , select update and delete using PHP and MySQL let’s have a look.

Database Design and Table which are used in this tutorial
Database name : dbtuts
Table name : users
Table Columns : first_name , last_name , user_city

Copy-Paste the following sql schema in your MySql database to create database and table.

CREATE DATABASE `dbtuts` ;
CREATE TABLE `dbtuts`.`users` (
`user_id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`first_name` VARCHAR( 25 ) NOT NULL ,
`last_name` VARCHAR( 25 ) NOT NULL ,
`user_city` VARCHAR( 45 ) NOT NULL
) ENGINE = InnoDB;

Continue Reading

Creating form in Zend Framework in Netbeans IDE

Posted by wasimxprt on August 27, 2015
Posted in: Zend Framework. Leave a comment

In this post I will show You how creating form with several form elements.
Begin with open Netbeans IDE and selecting from main menu File->New Project.

In New Project window in Categories section select PHP and in Projects section select PHP Application and click on Next button.

1

In Project Name field write MyForm. It is your project’s name.  Click on Next button.

Continue Reading

Developing PHP Application using Zend Framework in Netbeans

Posted by wasimxprt on August 27, 2015
Posted in: Zend Framework. Leave a comment

In this tutorial we will show how to create a simple Web Application using Zend Framework in Netbeans. Netbeans is one of the most popular feature rich IDE for Java based development. It also provides extensive features for Web-based Application development using PHP and PHP based framework like Zend. To prepare your IDE for developing Zend application you need to Download Zend Framework and keep it in a known place such as Documents folder for easier to find out.

Continue Reading

Posts navigation

← Older Entries
  • Recent Posts

    • RESTful Services API in PHP
    • Persistent Connections
    • Prepared Statements
    • Send e-Mail using PHPMailer and Gmail SMTP
    • PHP CRUD Application
  • PHP/MySQL

    • MySQL (2)
    • PHP (3)
    • Wordpress (29)
    • Zend Framework (2)
  • Recent Comments

    wasimxprt on Insert Featured Image In Style…
    Venugopal on Insert Featured Image In Style…
    myphpwordpress on Flexslider jquery conflict wit…
    kishore on Flexslider jquery conflict wit…
    cfnm videos on How to get the Current Page ID…
  • Archives

    • August 2015 (8)
    • November 2014 (2)
    • August 2014 (1)
    • June 2014 (2)
    • January 2014 (4)
    • September 2013 (4)
    • June 2013 (1)
    • April 2013 (2)
    • March 2013 (11)
    • December 2012 (1)
  • Social

    • View wasimxprt’s profile on Facebook
    • View wasimxprt’s profile on Twitter
    • View wasimxprt’s profile on LinkedIn
  • Blog Stats

    • 550 hits
  • Advertisements
Create a free website or blog at WordPress.com.
Wasimxprt
Create a free website or blog at WordPress.com.
Cancel