我正在使用此代码:
$image = mysqli_real_escape_string($dbc, $res[3][$i]);
$ res [3] [$ i]是网址。
然后我将$ image存储在Mysql DB中。但是当我检索它时,它们都被特殊字符搞砸了......(我的数据库是在utf8中)。
如何在mysql中存储一个url并将其恢复原状?
由于
答案 0 :(得分:-1)
其实我正在使用预备声明: $ image = mysqli_real_escape_string($ dbc,$ res [3] [$ i]); $ md5_of_title = md5($ title);
//$query = "INSERT IGNORE INTO scrap (date, journal, section, title, href, teaser, image, md5_of_title) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$query = "INSERT INTO scrap (date, journal, section, title, href, teaser, image, md5_of_title) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($dbc, $query);
/*i Integers;
d Doubles;
b Blobs;
s Everything Else;*/
mysqli_stmt_bind_param($stmt, "ssssssss", date('Y-m-d H:i:s'), $name, $section, $title, $href, $teaser, $image, $md5_of_title);
mysqli_stmt_execute($stmt);