< ?php
include_once('db.php');
$res = mysql_query("INSERT INTO apple VALUES('','Oracle')")
or die("sorry, database is busy!");
echo "Successful insertion";
?>
< ?php include_once('db.php'); $res = mysql_query("INSERT INTO apple VALUES('','Oracle')") or die("sorry, database is busy!"); echo "Successful insertion";
?>
if the insertion operation fails for some reason, the die function is invoked and the message “Sorry, database is busy!” is shown to the use and the script execution halts, and the “Successful insertion” message won’t be echoed.
Data in the database, as shown in the video: 1. Google 2. Apple 3. Microsoft 4. Oracle
There are many variations of include: include(); include_once();
require(); require_once();
require produces fatal error if the required file is not found. include produces warning when the file is not found. include_once and require_once makes sure the files are included only once and not included multiple times in the same file.
Twitter and other API’s return these kind of string Sun Mar 23 06:39:16 +0000 2008 which we store into a variable. using PHP standard function explode we separate the elements based on space.
Video Tutorial: Format Date and Insert Into Database Table: PHP