php print_r var_dump functions

  This chapter is about php print_r var_dump functions. These functions will generate output somewhat same but having few differences. Let’s see in details about PHP print_r var_dump functions: bool print_r(mixed val): print_r is used to print values in the human-readable form. The value can be a string, integer, double, array or object. If we use print_r to … Read more

Other MySql commands in PHP

Let’s see other MySql commands in PHP.   1. mysql_num_rows(): It returns the number of rows resulting from mysql_query() output. Example: <?php $query = “select * from employees”; $result = mysql_query($query, $con); if(!$result) { die(‘Error getting table data’, mysql_error); } echo “Number of Employees in database – “.mysql_num_rows($result); ?> 2. mysql_result(): This function will return … Read more

Update table data

  You can update table data by simply using update query in mysql_query function, just like other queries. Example: <?php require_once(“dbconnection.php”); $query = “update employees set name=”andy” where id = 2″; $result = mysql_query($query, $con); if(!$result) { die(“Error updatig data”,mysql_error()); } echo “Data updated successfully”; ?> As you see in above example using a function … Read more

Reading data from database table

  PHP is having multiple functions for reading data from database table. Those functions are mysql_fecth_array, mysql_fetch_assoc, mysql_fetch_object. We will see mysql_fetch_array in this chapter. While reading data from a table, these functions fetch data in the form of a single row at a time. Then we have to loop through to fetch all the … Read more

Inserting data in MySql table using PHP

mysql_query() For inserting data in MySql, PHP is having mysql_query() function where we can pass MySQL insert query to insert our data into database tables. Synatx: mysql_query(sql_query, connection); sql_query – its an sql query written in string format. connection –  its connection object returned from mysql_connect function. Before using this function lets create a new … Read more

Connecting database with PHP

We are having certain PHP functions for connecting database with PHP and using the database for various operations. Let’s see them in details. mysql_connect(): In PHP we are having mysql_connect() function to connect PHP application with MySql database. Syntax: connection mysql_connect(<server/host>,<username>,<password>); In above syntax: <server/host> – it’s a host or server of where your database is … Read more

Creating database and tables with phpMyAdmin

For creating database and tables, we can use phpmyadmin. We can use SQL commands with PHP to create a database table and insert, delete, update table records. We will see this in upcoming lessons. In this tutorial, I will show you how to create database and table directly using phpmyadmin. Creating database using below steps: You … Read more

MySql with PHP

The database is the most crucial part of every web application. We can use different types of databases with PHP but MySql is widely used. MySql is free and popular database system which can be used with PHP to create a web application with database handling. Let’s see in details MySql with PHP. Installation of … Read more

Session in PHP

What is Session? Session in PHP is used to store the information on the server which can be accessed at any page in your web application. Session store data on the server, unlike cookies which store data on client’s machine. Session data are stored in a file and that file resides on the server in … Read more

File upload using PHP forms

In File upload using PHP lets directly begin with the example. Consider below example and follow the steps to perform File upload using PHP. In the form add file input field. Set name, action and method attributes <form name=”file_upload” action=”uploads.php” method=”post” > <input type=”file” name=”photo” /> <input type=”submit” value=”Submit” /> </form> In above example, we have … Read more