I've built a website were I can enter data into an SQL database using php. The problem is when the user enter's an apostrophe the function crashes (SQL reasons). I think a work around would be to sanitise the script or use majic quotes in my php function (which I've attached at the end). I'm new to php and totally lost if this is the correct approach. If any one can point me in the right direction I'd really appreciate it. Allan
PHP function;
function insert_wisha($wisherID, $description, $duedate, $Location, $Time, $Price, $Details) {
$description = $this->real_escape_string($description);
if ($this->format_date_for_sql($duedate) == null) {
$this->query("INSERT INTO wishes (wisher_id, description, Location, Time, Price, Details)" .
" VALUES (" . $wisherID . ", '" . $description . "' ,'" . $Location . "', '" . $Time . "' , '" . $Price . "', '" . $Details . "')");
} else
$this->query("INSERT INTO wishes (wisher_id, description, due_date, Location, Time, Price, Details)" .
" VALUES (" . $wisherID . ", '" . $description . "', "
. $this->format_date_for_sql($duedate) . ", '" . $Location . "', '" . $Time . "', '" . $Price . "','" . $Details . "')");
}