Ho un campo tipo testo dove attraverso un form vado ad inserire dei dati, quando il testo che inserisco contiene ' mi restituisce questo errore
articoloYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1'
ora il fatto è che mi da questo uesto errore su questa versione di MySql 4.1.12 ma sulla versione 3.23.32 va perfettamente
Come devo fare a memorizzare i dati dai per evitare il problema dell'apice?
Io ora uso le funzione che usa Dreaweaver:
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
e poi passo il valore usando (campo) values (%s),
GetSQLValueString($_POST['campo_form'], "text"));
Spero di essermi spiegato
Grazie mille per l'aiuto
Max