Hi,
Brad gave me a suggestion to sanitize my input to prevent SQL injection. I have made some adjustments below, is this correct?
function sanitize($sql)
{
$sql = trim($sql);
if(get_magic_quotes_goc())
{
$sql = stripslashes($sql);
$sql = mysql_real_escape_string($sql);
return $sql;
}
$sql = $mysqli->query("SELECT * FROM url WHERE page = '" . $page . "' LIMIT 1");
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
if ($sql->num_rows > 0) {
while ($row = $sql->fetch_object())
{
$title = $row->title;
$description = $row->descr;
$keywords = $row->keywords;
}
} else {
$title = 'Set Default Title';
$description = 'Set Default Description';
$keywords = 'Set Default Keywords';
}
}