Basic PHP with MySQL Database

December 14th, 2010 by Nov Piseth Leave a reply »

IIC University of  technology
evening class: B205
file name: dbstudent.php
host: localhost
username: iicdatabase
password: 123456
Note: please un-comment for use some code.

<?php
$host   = "localhost";
$dbuser = "iicphp";
$dbpass = "123456";
$dbname = "iicdatabase";
$connect =  mysql_connect($host,$dbuser,$dbpass);
$dbselect = mysql_select_db($dbname,$connect);
/*$insert = mysql_query("INSERT INTO tblstudent (studname,gender,class) VALUES ('Bopha','Male','B2-05')",$connect);
if($insert){
echo "Insert Completed";
}
else{
echo "Insert Incompleted";
}*/
$delete = mysql_query("DELETE FROM tblstudent WHERE studid='1'",$connect);
if(!$delete){
echo "Could not Delete Record";
}
else{
echo "Record had been deleted";
}
/*$update = mysql_query("UPDATE tblstudent SET gender='Male' WHERE studid='1'",$connect);
if($update){
echo "Update Completed";
}
else{
echo "Update Incompleted";
}*/
/*if(!$connect){
echo "Databae is not Connected";
}
else{
echo "Database is Connected";
if(!dbselect){
echo "Database is not Selected";
}
else {
echo "Database is Selected";
}
}*/
?>
Advertisement

Comments are closed.

WP Facebook Auto Publish Powered By : XYZScripts.com