如何插入下面的字符串到MySQL:插入/更新MySQL來LONGTEXT Coulmn
$myValue ouputs: [Hey, this is a multi text file that has special characters like this ' and this '' and this ,,"", and this ''' and this '''' and this [email protected]$ and whatever]
但下面不會監守的特殊字符的工作:
$sql = "UPDATE `mytable` SET NEWS=('$myValue') WHERE _id='1'";
我不想手動逸出每chacarter(如添加一個「之前每」)
更新/插入應該應在開始[和結束](如在$ myvalue的看出)
EDIT(mysqli的)
$_myValue = mysqli_real_escape_string($myValue);
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE `mytable` SET NEWS='$_myValue' WHERE _id='1'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
你用什麼語言來生成輸出/ push到db? – atoms
Android AsyncTask – user3560827