予期せぬエラーで終了しました。" ); // 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 ); $keyword = mb_convert_encoding( $keyword, $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']; } // ジャンプボタンが押されたら表示を指定場所からに設定する if( $jump ) { $jyear = $_POST['jumpyear']; $jmon = $_POST['jumpmon']; $jday = $_POST['jumpday']; $startdate = sprintf( "%4d/%02d/%02d", $jyear, $jmon, $jday ); $page = strtotime( $startdate ); // unix timestamp } else { $jyear = date('Y'); $jmon = date('m'); $jday = date('d'); } // タイトル表示 print( "
memo diary
\n" ); // 検索結果の表示 if( $srch && $keyword ) { // データの取得 $sqlcmd = "select id, contents, date_format( itemdate, \"%Y/%m/%d\" ) as item_date"; $sqlcmd .= " from $RECORD_NAME"; $sqlcmd .= " where contents like \"%".$keyword."%\""; $sqlcmd .= " order by itemdate, contents"; // limit $MAX_MSG"; 暫定的に表示リミッタなし $result = mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); // データの表示 $i = 0; while( $data = mysql_fetch_array( $result )) { $id = $data['id']; $itemdate = $data['item_date']; $contents = $data['contents']; if( $currentdate != $itemdate ) { // 表示日付が変わるときには月日を表示 if( $i > 0 ) print( "
\n" ); // 予定を表示 $currentdate = $itemdate; // $md = substr( $currentdate, 5 ); // 年を削除 $md = $currentdate; // 年月日 print( "" ); // 色指定 $dateinfo = getdate( strtotime( $currentdate )); if( $dateinfo['wday'] == 0 ) { print( "" ); // 日曜日は赤色 print( "$md" ); print( "" ); } else { print( "$md" ); // 月日を表示 } } print( " " ); print( "" ); // 編集リンク print( "$contents" ); print( "" ); } mysql_close( $sqlid ); } else { // データの取得 $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, contents limit $MAX_MSG"; $result = mysql_query( $sqlcmd ) or die( "

SQLコマンド実行エラー

$sqlcmd

" ); // データの表示 $i = 0; $currentdate = $startdate; $md = substr( $currentdate, 5 ); // 年を削除 print( "" ); // 色指定 $dateinfo = getdate( strtotime( $currentdate )); if( $dateinfo['wday'] == 0 ) { print( "" ); // 日曜日は赤色 print( "$md" ); print( "" ); } else { print( "$md" ); // 月日を表示 } while( $data = mysql_fetch_array( $result )) { $id = $data['id']; $itemdate = $data['item_date']; $contents = $data['contents']; if( $currentdate != $itemdate ) { // 表示日付が変わるときには月日を表示 $nexttime = strtotime( "+ 1 day", strtotime( $currentdate )); $next = date( "Y/m/d", $nexttime ); // 次の日 // 予定がない日付を表示 while( $next != $itemdate ) { $currentdate = $next; $md = substr( $next, 5 ); print( "
\n" ); print( "" ); // 色指定 $dateinfo = getdate( strtotime( $currentdate )); if( $dateinfo['wday'] == 0 ) { print( "" ); // 日曜日は赤色 print( "$md" ); print( "" ); } else { print( "$md" ); // 月日を表示 } print( "\n" ); $next = date( "Y/m/d", strtotime( "+ 1 day", strtotime( $currentdate ))); // 次の日 if( $i >=14 ) break; // 2週間のみ表示 } print( "
\n" ); // 予定を表示 $currentdate = $itemdate; $md = substr( $currentdate, 5 ); // 年を削除 print( "" ); // 色指定 $dateinfo = getdate( strtotime( $currentdate )); if( $dateinfo['wday'] == 0 ) { print( "" ); // 日曜日は赤色 print( "$md" ); print( "" ); } else { print( "$md" ); // 月日を表示 } } print( " " ); print( "" ); // 編集リンク print( "$contents" ); print( "" ); if( $i >=14 ) break; // 2週間のみ表示 } print( "
\n" ); mysql_close( $sqlid ); } // 登録画面を表示する print( "\n" ); if( $edit_itemdate == "" ) $edit_itemdate = $today; print( "
\n" ); print( "\n" ); print( "\n" ); print( "\n" ); // print( "日付
\n" ); $etime = strtotime( $edit_itemdate ); $eyear = date( "Y", $etime ); $emon = date( "m", $etime ); $eday = date( "d", $etime ); print( "日付" ); disp_form_date( 'edit', $eyear, $emon, $eday ); 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" ); // ページの直接移動 print( "
\n" ); print( "\n" ); disp_form_date( 'jump', $jyear, $jmon, $jday ); print( "\n" ); print( "
\n" ); // 検索フォーム print( "
\n" ); print( "\n" ); print( "\n" ); print( "\n" ); print( "
\n" ); // メイン処理の終了 ----------------------------------------------------------------------------------------- // 日付の選択フォーム function disp_form_date( $id, $year, $mon, $day ) // *year, *mon, *day { print( "\n" ); // print( "年\n" ); print( "\n" ); // print( "月\n" ); print( "\n" ); // print( "日\n" ); } // サブルーチン定義終了 ?>