予期せぬエラーで終了しました。" ); // HTTP入力文字エンコーディングの検出と変換 $input_code = mb_http_input( "P" ); if( $input_code == "" ) $input_code = "SJIS"; // 暫定デフォルト $inter_code = mb_internal_encoding(); $contents = mb_convert_encoding( $contents, $inter_code, $input_code ); // 表示ページの設定 if( !$page ) $page = time(); // today if( $prev ) $page -= ( 7 * 24 * 60 * 60 ); // 1week if( $next ) $page += ( 7 * 24 * 60 * 60 ); // 1week $startdate = date( "Y/m/d", $page ); // データベース接続 $sqlid = mysql_connect( $DB_HOST, $DB_ID, $DB_PASS ) or die( "

サーバ接続エラー

"); mysql_select_db( $DB_NAME ) or die( "

データベース接続エラー

"); // 登録ボタンが押されたら新規登録する if( $resist ) { if( $contents == "" || $itemdate == "" ) die( "

未入力欄がありますエラー

" ); $sqlcmd = "insert into $RECORD_NAME ( contents, itemdate )"; $sqlcmd .= " values ( \"$contents\",\"$itemdate\" )"; mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); } // 削除ボタンが押されたら削除する if( $delcmd ) { $sqlcmd = "delete from $RECORD_NAME where id = ".$id; mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); } // 修正ボタンが押されたら修正登録する if( $update ) { if( $contents == "" || $itemdate == "" ) die( "

未入力欄がありますエラー

" ); $sqlcmd = "update $RECORD_NAME set"; $sqlcmd .= " contents=\"$contents\",itemdate=\"$itemdate\""; $sqlcmd .= " where id=$id"; mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); } // 編集リンクが押されたら編集データ読み込む if( $editcmd ) { $sqlcmd = "select id,"; $sqlcmd .= " contents,"; $sqlcmd .= " date_format( itemdate, \"%Y/%m/%d\" ) as item_date"; $sqlcmd .= " from $RECORD_NAME where id=$id"; $result = mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); $data = mysql_fetch_array( $result ); $edit_id = $data['id']; $edit_contents = $data['contents']; $edit_itemdate = $data['item_date']; } // タイトル表示 print( "memo diary
\n" ); // データの取得 $pagedate = date( "Y/m/d", $page ); $sqlcmd = "select id, contents, date_format( itemdate, \"%Y/%m/%d\" ) as item_date"; $sqlcmd .= " from $RECORD_NAME"; $sqlcmd .= " where to_days( \"$pagedate\" ) <= to_days( itemdate )"; $sqlcmd .= " order by itemdate limit $MAX_MSG"; $result = mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); // データの表示 $i = 0; $currentdate = $startdate; $md = substr( $currentdate, 5 ); // 年を削除 print( "" ); // 色指定 print( "$md" ); // 月日を表示 while( $data = mysql_fetch_array( $result )) { $id = $data['id']; $itemdate = $data['item_date']; $contents = $data['contents']; if( $currentdate != $itemdate ) { // 表示日付が変わるときには月日を表示 print( "
\n" ); $currentdate = $itemdate; $md = substr( $currentdate, 5 ); // 年を削除 print( "" ); // 色指定 print( "$md" ); // 月日を表示 } print( "" ); // 編集リンク print( "$contents" ); } print( "
\n" ); mysql_close( $sqlid ); // 登録画面を表示する if( $edit_itemdate == "" ) $edit_itemdate = $today; print( "
\n" ); print( "\n" ); print( "\n" ); print( "\n" ); print( "日付
\n" ); print( "
\n" ); if( $editcmd ) { print( "\n" ); print( "\n" ); } print( "\n" ); print( "
\n" ); // ページをめくるリンク $pagetoday = time(); print( "prev" ); print( "|" ); print( "today" ); print( "|" ); print( "next" ); print( "\n

\n" ); // メイン処理の終了 ?>