私の問題の小さな例を取り上げます。このコードは 6 時間前には完璧でしたが、今は問題があり、それが何かわかりませんか?
これが私の小さなphpです。問題がmysql_real_escape_stringであることがわかりましたが、これをすばやく修正する方法がわかりません。
<?php
// database connection
require_once 'includes/inc/config.php';
$date = new DateTime();
$newtime = $date->format('U');
// we are taking post_text = <img id="profile_pic" width="200px" height="600px" src="image/user/1.jpg">
if (isset($_POST['submit-post'])) {
$content = mysql_real_escape_string($_POST['post_text']);
if ($got != "" && $send != "" && strlen(trim(preg_replace('/\xc2\xa0/',' ',$content))) != 0) {
$postnow = mysql_query("INSERT INTO `comment`(`send`,`got`,`content`,`time`) VALUES ('$send','$got','$content','$newtime')");
}
}
?>
ディスプレイ用
<?php
require_once 'library/all/HTMLPurifier.auto.php';
// reading content which was saved when user posted comment
// getting it from database ex: <img id="profile_pic" width="200px" height="600px" src="image/user/1.jpg">
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$content = $purifier->purify($content);
// and then echo
echo $content;
?>
すべてのページに私の投稿の短い表示が表示されます。
これが私の出力です
これは壊れた画像です。壊れていない前に、何が起こったのでしょうか?
<img id=\"profile_pic\" width=\"200px\" height=\"600px\" src=\"image/user/1.jpg\">
PS: これは localhost でも問題なく動作します。サーバープロバイダーが何かをアップグレードしたり、そのようなものをアップグレードしたりすると、少し混乱します。何も思いつきません。皆さん、ありがとうございました。