sql
1/* MySQL */ 2 3create database bbs_php; 4 5use bbs_php; 6 7grant all on bbs_php.* to bbs_php@localhost identified by '****'; 8 9create table bbs( 10 id int not null auto_increment primary key, 11 name varchar(100), 12 title varchar(32) not null, 13 textbody text not null, 14 date datetime, 15 pass char(4) not null 16); 17
php
1/* write.php */ 2 3// データベースへ接続 4 define('DB_NAME', 'bbs_php'); 5 define('DB_USER', 'bbs_php'); 6 define('DB_PASS', '****'); 7 define('PDO_DSN', 'mysql:host=localhost;dbname='.DB_NAME); 8 9 try { 10 // PDOへ接続 11 $db = new PDO(PDO_DSN, DB_USER, DB_PASS); 12 // エラーを表示するための設定 13 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 14 15 // プリペアドステートメントの作成 16 $stmt = $db->prepare("insert into bbs (name, title, textbody, date, pass) values (:name, :title, :textbody, noe(), :pass)"); 17 18 // パラメータの割り当て 19 $stmt->bindParam(':name', $name, PDO::PARAM_STR); 20 $stmt->bindParam(':title', $title, PDO::PARAM_STR); 21 $stmt->bindParam(':textbody', $text_body, PDO::PARAM_STR); 22 $stmt->bindparam(':pass', $pass, PDO::PARAM_INT); 23 24 // クエリの実行 25 $stmt->execute(); 26 27 echo "書き込みました!"; 28 29 } catch(PDOException $e) { 30 echo $e->getMessage(); 31 exit; 32 }
エラーメッセージ
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION bbs_php.noe does not exist
なぜですか? bbs_phpは存在しないみたいなこと言っていますが、どうしてですか?
うまく作れてるはずです・・・
他のエラーメッセージはなかったです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/08/08 23:51