im teaching MySQLi to make my site not vulnerable to SQL injection (which is now), but I get confused when I try to "translate" my old queries into MySQLi statements, so I hope you can help me with some examples, so I I can get it. Many thanks!
Site Counter Update
$sql = "UPDATE post SET counter = counter+1 WHERE id=".$tget;
Sort my comments
$info=mysql_query("SELECT * FROM `comments` WHERE idpost=" . $tget . " AND active=1 ORDER BY datetime DESC");
Save Comment
$sql = "INSERT INTO `comments` (`id`, `idpost`, `comment`, `datetime`, `author`, `active`) VALUES (NULL, '" . addslashes($_POST['idcomment']) . "', '" . addslashes($_POST['comment']) . "', NOW(), '" . addslashes($_POST['name']) . "', '1');";
If you can explain to me how to go from here to MySQLi, I can finish with other queries.
And by the way, if you ( expert ) think that there is another way to protect me from SQL injections better than MySQLi, tell me about it.
source
share