I am encountering a problem updating a text field in a MySQL table via PHP.
If there is a single quotation mark ' anywhere in the contents of the field, it will not update. Remove the quotation marks, and it updates fine. Here is the script.
Code: Select all
require("openfirstdb.php");
$sq = "SELECT *";
$sq.= " FROM author ";
$sq.= " WHERE AUTO_ID = 0";
$rs = mysql_db_query($DBname,$sq,$link);
while ($row=mysql_fetch_array($rs)){
if($row["pass"]==$pass){ //checks password
$sq2 = "UPDATE author set ";
$sq2.= " body = '$sbody' ,";
$sq2.= " contact = '$contact', ";
$sq2.= " news = '$snews' ";
$sq2.= " WHERE AUTO_ID = 0";
$result = mysql_db_query($DBname,$sq2,$link);
if ($result){
print("Contents successfully updated.");
}
else {
print ("Contents not successfully updated.");
}
}
}Any suggestions?