In the old mysql () code, to avoid the line, I did this:
t.TeacherUsername = '".mysql_real_escape_string($teacherusername)."'
I am changing my code to mysqli, but what I want to know for sure and be safe to avoid a line in mysqli is as follows:
t.TeacherUsername = '".mysqli_real_escape_string($teacherusername)."'
Also for connecting to mysqli database it looks like this:
$username="xxx"; $password="xxx"; $database="xxx"; mysqli_connect('localhost',$username,$password); mysqli_select_db($database) or die( "Unable to select database");
All I did was change mysql to mysqli, is this correct?
UPDATE:
Now this is the correct way to connect to the database using mysqli:
$username="xxx"; $password="xxx"; $database="mobile_app"; $mysqli = new mysqli("localhost", $username, $password, $database); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }
source share