Skip to main content

Posts

Showing posts from December, 2015

How to implement PDO in PHP

Introduction PHP PDO  Connecting to SQL: 1. new PDO("sqlsrv:Server=$servername; Database=$dbname",$username,$password); Connecting to Oracle:        1. new PDO("OCI:dbname=accounts;charset=UTF-8","username","password"); Connecting to PgSQL: 1. $db = new PDO("pgsql:dbname=pdo;host=localhost","username", "password"); Connecting to MySQL: 1. $db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password'); 2. $db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password', array(PDO::ATTR_EMULATE_PREPARES => false,                                         PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); 3. $db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password');           $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_

How to Upload file using jQuery Ajax PHP

How to Upload file using jQuery Ajax PHP Example 1: Single file upload using jQuery and Ajax Step 1: Create Html Form <form id="data" method="post" enctype="multipart/form-data">     <label>First Name :</label><input type="text" name="firstname" value="" />     <label>Last Name :</label><input type="text" name="lastname" value="" /> <label>Email :</label><input type="email" name="email" value="" /> <label>Contact Number :</label><input type="text" name="phone" value="" />     <label>Upload Profile :</label><input name="image" type="file" />     <input type="submit" value="Submit" /> </form> Step 2: Now create javascript for file uploading       <script>   $