Category Archives: PHP

PHP – Inserting the Data to the Database

Inserting data to the database is the same process as creating or deleting the database. You can use the same function mysql_query to add the data to the table. Example- <?php $db_host = ‘localhost:3036’; $db_user = ‘root’; $db_pass = ‘rootpassword’; $db_conn = mysql_connect($db_host, $db_user, $db_pass); if(! $db_conn ) { die(‘Connection failed: ‘ . mysql_error()); } echo ‘Success’; $db_sql… Read More »

Deleting the Database using PHP

You can delete the database in the same manner as you created the database using the mysql_query function. Example <?php $db_host = ‘localhost:3036’; $db_user = ‘root’; $db_pass = ‘rootpassword’; $db_conn = mysql_connect($db_host, $db_user, $db_pass); if(! $db_conn ) { die(‘Error: ‘ . mysql_error()); } echo ‘Success’; $db_sql = ‘DROP Database demo_db’; $db_retval = mysql_query( $sql, $conn ); if(! $db_retval… Read More »

Creating a Database using PHP

Creating Database PHP allows the use of mysql_query function to create a database. But in order to create and delete a database, you must have admin rights on the database. This function takes two parameters to create a database. Syntax bool mysql_query (sql, connection); Where, SQL is the query with which you will create the database. Connection (optional)… Read More »

PHP and MySQL

Well, PHP has support for almost every database like oracle, Sybase but developers mostly prefer MySQL database over others. Before starting with the programming we need to have some pre-requisite for the database part. You should have downloaded the compatible version of MySQL for your PHP. Create a database that will store your PHP data and connect with… Read More »

PHP – Date and Time

PHP allows you to use many date functions along with many modifiers that help you to perform some operations on a date. You can even manipulate date using PHP date and time functions. Use of time() function If you want all the information about the current date and time, then PHP helps you with time() function. This function… Read More »

PHP-Regular Expression

A regular expression can be considered as the sequence of characters that allows you to use the PHP functionality of pattern matching. Regular expression helps you to search for a particular string, replace one string from another string. PHP supports two types of regular expressions on which you can perform different functions. POSIX regular expression PERL style regular… Read More »