非常に興味深い問題があります。値の一部のみがデータベースに入力されています。
フォームを含むページがあります。ユーザーはフォームに入力して送信します。すべての POST 値が正しく、データベースに送信されています。1 つの特定の値 ($criteria) は、文字列の最後の部分のみを送信しています。$criteria の値をエコーするとすべて表示されますが、mysqlAdmin で表示するとその一部しか表示されません。
提出する必要があります:
Communication | 1 | dsafadf | Customer Service | 2 | asdfadf | Dependability | 3 | asdfadsf | Initiative | 4 | dsafadsfa | Job Knowledge | 5 | dsadafsadsf | Judy | 1 | asdfasdf | Punctuality | 2 | asdfdasdfadsf |
しかし、データベースでは - | しか得られません。時間厳守 | 2 | asdfdasdfadsf | asdfdasdfadsf |
mysqlAdmin を使用して値を手動で追加しようとしましたが、正常に動作します。
追加情報が必要な場合は、追加します。
みんな、ありがとう!!
ここに私の挿入スクリプトがあります:
public function insertReview() {
$fk_employee = $_POST['fk_employee'];
// Current Date returned from JQuery and formatted to add to DB.
$cdate = $_POST['current_date'];
$current_date = explode("/", $cdate);
$cmonth = $current_date[0];
$cday = $current_date[1];
$cyear = $current_date[2];
$current_dateA = array($cyear, $cmonth, $cday);
$review_date = implode("-", $current_dateA);
// Review Begin Date returned from JQuery Datepicker and formatted to add to DB.
$bdate = $_POST['r_period_begin'];
$begin_date = explode("/", $bdate);
$bmonth = $begin_date[0];
$bday = $begin_date[1];
$byear = $begin_date[2];
$begin_dateA = array($byear, $bmonth, $bday);
$r_period_begin = implode("-", $begin_dateA);
// Review End Date returned from JQuery Datepicker and formatted to add to DB.
$edate = $_POST['r_period_end'];
$end_date = explode("/", $edate);
$emonth = $end_date[0];
$eday = $end_date[1];
$eyear = $end_date[2];
$end_dateA = array($eyear, $emonth, $eday);
$r_period_end = implode("-", $end_dateA);
// Criteria
$criterias = $_POST['criteria'];
//var_dump($criterias);
$criteriaValue = $_POST['criteriaValue'];
//var_dump($criteriaValue);
$comments = $_POST['Comments'];
foreach ($criteriaValue as $key => $value ){
foreach( $criterias as $criteria ){
if( $criteria == $key ){
$string1 = $key;
foreach( $comments as $comment => $comm ){
if( $string1 == $comment ){
$string3 = $comm;
}
}
}
}
//echo $key . '<br>';
foreach ( $value as $result ){
$string2 = $result;
}
$criteria = mysql_real_escape_string( $string1 . ' | ' . $string2 . ' | ' . $string3 . ' | ' );
echo $criteria;
}
// End of Criteria
$job_knowledge = $_POST['job_knowledge'];
$jk_comments = $_POST['jk_comments'];
$work_quality = $_POST['work_quality'];
$wq_comments = $_POST['wq_comments'];
$attendance = $_POST['attendance'];
$attend_comments = $_POST['attend_comments'];
$initiative = $_POST['initiative'];
$init_comments = $_POST['init_comments'];
$communication = $_POST['communication'];
$comm_comments = $_POST['comm_comments'];
$dependability = $_POST['dependability'];
$depend_comments = $_POST['depend_comments'];
$customer_service = $_POST['customer_service'];
$cs_comments = $_POST['cs_comments'];
$overall_rating = $_POST['overall_rating'];
$additional_comments = $_POST['additional_comments'];
$goals = $_POST['goals'];
$conn = parent::connect();
$sql = "INSERT INTO " . TBL_EMPLOYEE_REVIEW . " (
fk_employee,
review_date,
r_period_begin,
r_period_end,
job_knowledge,
jk_comments,
work_quality,
wq_comments,
attendance,
attend_comments,
initiative,
init_comments,
communication,
comm_comments,
dependability,
depend_comments,
customer_service,
cs_comments,
overall_rating,
additional_comments,
goals,
criteria
) VALUES (
:fk_employee,
:review_date,
:r_period_begin,
:r_period_end,
:job_knowledge,
:jk_comments,
:work_quality,
:wq_comments,
:attendance,
:attend_comments,
:initiative,
:init_comments,
:communication,
:comm_comments,
:dependability,
:depend_comments,
:customer_service,
:cs_comments,
:overall_rating,
:additional_comments,
:goals,
:criteria
)";
try {
$st = $conn->prepare( $sql );
$st->bindValue( ":fk_employee", $fk_employee, PDO::PARAM_STR );
$st->bindValue( ":review_date", $review_date, PDO::PARAM_STR );
$st->bindValue( ":r_period_begin", $r_period_begin, PDO::PARAM_STR );
$st->bindValue( ":r_period_end", $r_period_end, PDO::PARAM_STR );
$st->bindValue( ":job_knowledge", $job_knowledge, PDO::PARAM_STR );
$st->bindValue( ":jk_comments", $jk_comments, PDO::PARAM_STR );
$st->bindValue( ":work_quality", $work_quality, PDO::PARAM_STR );
$st->bindValue( ":wq_comments", $wq_comments, PDO::PARAM_STR );
$st->bindValue( ":attendance", $attendance, PDO::PARAM_STR );
$st->bindValue( ":attend_comments", $attend_comments, PDO::PARAM_STR );
$st->bindValue( ":initiative", $initiative, PDO::PARAM_STR );
$st->bindValue( ":init_comments", $init_comments, PDO::PARAM_STR );
$st->bindValue( ":communication", $communication, PDO::PARAM_STR );
$st->bindValue( ":comm_comments", $comm_comments, PDO::PARAM_STR );
$st->bindValue( ":dependability", $dependability, PDO::PARAM_STR );
$st->bindValue( ":depend_comments", $depend_comments, PDO::PARAM_STR );
$st->bindValue( ":customer_service", $customer_service, PDO::PARAM_STR );
$st->bindValue( ":cs_comments", $cs_comments, PDO::PARAM_STR );
$st->bindValue( ":overall_rating", $overall_rating, PDO::PARAM_STR );
$st->bindValue( ":additional_comments", $additional_comments, PDO::PARAM_STR );
$st->bindValue( ":goals", $goals, PDO::PARAM_STR );
$st->bindValue( ":criteria", $criteria, PDO::PARAM_STR );
$st->execute();
parent::disconnect( $conn );
} catch ( PDOException $e ) {
parent::disconnect( $conn );
die( "Query failed: " . $e->getMessage() );
}
}