I've just converted my code from mysql
to mysqli
and I used Oracle's converter:
https://wikis.oracle.com/display/mysql/Converting+to+MySQLi
It was my understanding from various questions/answers on Stack Overflow that inputs do not need to be sanitised if you are using mysqli
. However it appears this isn't the case - even though I'm on mysqli
- i can still input something with an inverted comma e.g. what's
and it returns the error as it will try to merge anything after the '
with the rest of my code.
Am I doing something wrong? If I still need to sanitise my input values after using mysqli
how could I do it?
UPDATE
If I run a function like this on my inputs would that be enough?
function sanitise($str){
$string = htmlspecialchars($str);
$string = mysql_real_escape_string($str);
return $str;
}