Example #1
0
<?
mysql_connect('localhost', 'istorrent', 'torrenter1') or die(msqyl_error());
mysql_select_db('istorrent') or die(msqyl_error());
mysql_query("select * from innmyndir") or die(mysqk_error());
?>
Example #2
0
<?php

// データベースに接続
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('データベースに接続できません: ' . mysqk_error());
}
// データベースを選択
mysql_select_db('oneline_bbs', $link);
$errors = array();
// POSTなら保存処理実行
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // 名前が正しく入力されているかチェック
    $name = null;
    if (!isset($_POST['name']) || !strlen($_POST['name'])) {
        $errors['name'] = '名前を入力してください';
    } else {
        if (strlen($_POST['name']) > 40) {
            $errors['name'] = '名前は40字以内で入力してください';
        } else {
            $name = $_POST['name'];
        }
    }
    // ひとことが正しく入力されているかチェック
    $comment = null;
    if (!isset($_POST['comment']) || !strlen($_POST['comment'])) {
        $errors['comment'] = 'ひとことを入力してください';
    } else {
        if (strlen($_POST['comment']) > 200) {
            $errors['comment'] = 'ひとことは200文字以内で入力してください';
        } else {