I am making a program for updating the database and by the time I clicked the update button it displays an error like this:
Notice: Undefined offset: 2 in C:\xampp\htdocs\maritime_database\students_entry.php on line 103
Notice: Undefined offset: 1 in C:\xampp\htdocs\maritime_database\students_entry.php on line 103
it is somewhere in the line 103 and this is the code:
<?php
if($opr=="upd")
{
$sql_upd=mysql_query("SELECT * FROM students WHERE stud_id=$id");
$rs_upd=mysql_fetch_array($sql_upd);
list($y,$m,$d)=explode('-',$rs_upd['dob']);
?>
Why you parse date manually ? PHP has date built-in function :
<?php
if($opr=="upd"){
$sql_upd = mysql_query("SELECT * FROM students WHERE stud_id=$id");
$rs_upd = mysql_fetch_array($sql_upd);
$dob = strtotime($rs_upd['dob']); // Convert into UNIX time
$y = date("Y",$dob); // Extract Year
$m = date("m",$dob); // Extract Month
$d = date("d",$dob); // Extract Day
echo "Day : ".$d."
";
echo "Month : ".$m."
";
echo "Year : ".$y."
";
}
?>