javascript - undefined offset error in php somewhere in the date and time error -


i making program updating database , time clicked update button displays error 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 somewhere in line 103 , code:

<?php  if($opr=="upd") {     $sql_upd=mysql_query("select * students stud_id=$id");     $rs_upd=mysql_fetch_array($sql_upd);     list($y,$m,$d)=explode('-',$rs_upd['dob']); ?> 

why parse date manually ? php has date built-in function :

<?php  if($opr=="upd"){     $sql_upd = mysql_query("select * students stud_id=$id");     $rs_upd = mysql_fetch_array($sql_upd);     $dob = strtotime($rs_upd['dob']); // convert unix time     $y = date("y",$dob); // extract year     $m = date("m",$dob); // extract month     $d = date("d",$dob); // extract day     echo "day : ".$d."\n";     echo "month : ".$m."\n";     echo "year : ".$y."\n";  } ?> 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -