Object Oriented PHP tutorial-Detailed Guide

What is Object Oriented PHP? Object Oriented PHP: Before looking into what is object oriented PHP, let’s see some background. Look around you! Everything around you is an object. Even you yourself is an object. Every object has a specific type. Like you, a male or a female is of type Human. The chair you are … Read more

Date and time function in PHP

Date and time function in PHP You may require a date and time functionality in almost every application you make. You will learn about a date and time function in PHP here. As date and time are a very common and essential part of our day to day life, you should know how you can … Read more

Suppressing errors in PHP

Many times you find that while coding you get errors or warnings in the output. If you don’t want to show those errors in your output or for suppressing errors in PHP, you can use two methods. Adding @ symbol before the line where you think the error may occur. Adding function error_reporting(0) before/top of … Read more

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

Deleting data from a table

For deleting data from a table, you can again use the same mysql_query function. You need to pass MySQL delete query in this function. Example: <?php $query = “delete from employees where id = 3”; $result = mysql_query($query, $con); if(!$result) { die(“Error deleting data”,mysql_error()); } echo “Data deleted successfully”; ?> You can use all the other SQL … 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