I've got the good old problem with apostrophe's. I have built a website using PHP and linking to a MySQL database and information from a textarea is being sent to the database. When an apostrophe is included in the content of the textarea...nothing is sent to the database at all. I've contacted my Hosting provider and they have recently upgrade the PHP to 5.1.6 and have something called "magic quotes" turned off when it was still activated for other websites I've done. They will not activate the magic quotes for the server that's now hosting the new site as its not a dedicated server and there are other people to consider.
They have said I can use something called addslashes() which apparently does the same...but I don't know how to incorporate it into my coding.
The form I have calls up a content checker file which uses a case statement to determine how to deal with the posted information see below:
case "updatecase": // Update Case Studies
$query = buildQuery($_POST, "UPDATE", "laplace_case");
if( dbit($query)==FALSE ){
sendHeader("../login.php");
}else{
sendHeader("../viewCase.php");
}
break;
This case statement calls up the UPDATE function from another include file that looks like:
case "UPDATE":
$query = "UPDATE $table SET ";
while (list ($key, $value) = each($getArray)) {
$query .= " $key = '$value',";
}
$query = ereg_replace(",$","",$query);
if(isset($getArray[itemID])){
$query .= " WHERE itemID = '$getArray[itemID]'";
}elseif(isset($getArray[id])){
$query .= " WHERE id = '$getArray[id]'";
}elseif(isset($getArray[id])){
$query .= " WHERE id = '$getArray[id]'";
}
break;
Any help would be gratefully appreciated.
Cheers