私はダブルワードとシングルクォートを許可するwordpressのmysqlデータベースにいくつかのタイトルを保存しようとしています。だから私のような文字列を挿入することができるようにしたい:wordpressデータベースに一重引用符と二重引用符を挿入してください
A man's dog walked into the bar
The "main reason" it does not work
It's time to announce "The Show" in an hour
私のコードは、次のようになります。
$question_id = filter_var($_REQUEST['question_id'], FILTER_SANITIZE_NUMBER_INT);
$feedback_correct = preg_replace("/[^a-zA-Z0-9'\"?_\. !&-]+/","",sanitize_text_field($_REQUEST['feedback_correct']));
$feedback_incorrect = preg_replace("/[^a-zA-Z0-9'\"?_\. !&-]+/","",sanitize_text_field($_REQUEST['feedback_incorrect']));
//preg_replace is to strip out any characters we dont want in the title like "<>|}{[]/"
$data = array(
'feedback_correct' => $feedback_correct,
'feedback_incorrect' => $feedback_incorrect
);
$update_feedback = $eot_quiz->updateQuestion($data, $question_id);
そしてupdateQuestion機能:データベースへの旅行の後
私の弦は次のようになります:
A man
*文字列は
The "main reason" it does not work
*
It
*文字列は、私はこれらの文字列が挿入されたのですかどのように単一引用符
後に切断された二重引用符でOKになり、単一引用符の後に切断されますdbで正しく?前もって感謝します。
表示コード:
<?php
$quiz_question = $eot_quiz->get_question_by_id($question_id);
?>
<div class="bs">
<div class="panel panel-default">
<form method="POST" action="#">
<div class="panel-heading">
<h3 class="panel-title"><?= $quiz_question['quiz_question']?></h3>
</div>
<div class="panel-body">
<div class="form-group">
<label for="feedback_correct">Feedback for correct answer</label>
<input type="text" class="form-control" name="feedback_correct" placeholder="Correct Feedback" value='<?= $quiz_question['feedback_correct']?>'>
</div>
<div class="form-group">
<label for="feedback_incorrect">Feedback for incorrect answer</label>
<input type="text" class="form-control" name="feedback_incorrect" placeholder="Incorrect Feedback" value='<?= $quiz_question['feedback_incorrect']?>'>
</div>
<input type='hidden' name='question_id' value="<?= $question_id ?>" />
<input type='hidden' name='quiz_id' value="<?= $quiz_id ?>" />
<input type='hidden' name='subscription_id' value="<?= $subscription_id ?>" />
<input type='hidden' name='feedback' value="true" />
<button type="submit" class="btn btn-default">Update Feedback</button>
</div>
<div class="panel-footer"><a href="/dashboard/?part=update_quiz_questions&question_id=<?= $question_id?>&quiz_id=<?= $quiz_id?>&subscription_id=<?= $subscription_id ?>" class="btn btn-success pull-right">Take me back to the Question</a><div style="clear:both"></div></div>
</form>
</div>
</div>
[Bobby Tables](http://bobby-tables.com/) – ctwheels
いいえ、ここにはボビーのテーブルはありません。 'wpdb'コードは、適切なバインドパラメータを使用します。 –
私はバビーテーブルを試しました: $ result = $ wpdb-> update(TABLE_QUIZ_QUESTION、$ data、array( 'ID' => $ id)、array( '%s'、 '%s')); 同じ結果 –