connect_error) ohno($db->connect_error); $query = "DROP TABLE IF EXISTS monthsTable"; $result= $db->query($query); if(!$result) ohno( "Table Drop Failed? ".$db->connect_error); $query = "create table monthsTable( monthsID INT NOT NULL, monthName CHAR(10) NOT NULL, monthDays INT(2) NOT NULL )"; $result= $db->query($query); if(!$result) ohno( "Could not create table: ".$db->connect_error); $arr = getMonths('mfc211_io.txt'); for($i=0; $i<(count($arr));$i++){ $data = explode(",",$arr[$i]); $query = "INSERT INTO monthsTable VALUES". "('$data[0]','$data[1]','$data[2]')"; $result= $db->query($query); if(!$result) ohno( "Could not add data: ".$db->connect_error); } echo "

\nSuccess!

"; } ending(); function begin(){ echo <<< _END MySQL Page

MYSQL Page



_END; } function ending(){ echo <<< _END _END; } function getMonths($input) { $fh = fopen ($input, 'r' ) or die ( "Can't find/open file" ); $arr; while ( ! feof ( $fh ) ) { $arr [] = fgets ( $fh ); } return $arr; } function uhoh($error){ echo "

".$error; echo "Unsuccessful

"; ending(); exit(); } ?>