Video tutorial illustrates INSERTION of records into database via PHP script.
Simple / basic insertion operation:
First connect to the database.
Next, using simple MySQL query.
index.php
< ?php
include_once('db.php');
if(mysql_query("INSERT INTO apple VALUES('','Oracle')"))
echo "Successful Insertion!";
else
echo "Please try again";
?>
make sure to watch other video about connecting to the database, to understand include_once(‘db.php’);
Video Tutorial: Insertion of Records into Database: PHP & MySQL
die function:
< ?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