I use some modified code from Dreamweaver:
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "''";
break;
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
}
return $theValue;
}
$insertRec = sprintf("INSERT INTO news (newsId, datum, expDate, titel, subtitel, text1, text2, text3, image1, image2, logo, taal, type, hyperlink) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['newsId'], "int"),
GetSQLValueString($HTTP_POST_VARS['datum'], "date"),
GetSQLValueString($HTTP_POST_VARS['expDate'], "date"),
GetSQLValueString($HTTP_POST_VARS['titel'], "text"),
GetSQLValueString($HTTP_POST_VARS['subtitel'], "text"),
GetSQLValueString(str_replace("\n", "<br>", $HTTP_POST_VARS['text1']), "text"),
GetSQLValueString(str_replace("\n", "<br>", $HTTP_POST_VARS['text2']), "text"),
GetSQLValueString(str_replace("\n", "<br>", $HTTP_POST_VARS['text3']), "text"),
GetSQLValueString(txtConvert($_FILES['image1']['name']), "text"),
GetSQLValueString(txtConvert($_FILES['image2']['name']), "text"),
GetSQLValueString(txtConvert($_FILES['logo']['name']), "text"),
GetSQLValueString($HTTP_POST_VARS['taal'], "text"),
GetSQLValueString($HTTP_POST_VARS['type'], "text"),
GetSQLValueString($HTTP_POST_VARS['hyperlink'], "text"));
mysql_query($insertRec, $conn) or die(mysql_error());