What is the proper format to use variables within SQL queries? Yes I know my code is not secure for because its not hashed and other flaws but I just can't get it to work.
include 'config/database.php'; // DB connection.
$password = mysql_real_escape_string($_POST['password']);
$sql = 'INSERT INTO `login` (`id`, `username`, `password`, `question`) VALUES (NULL, \'test\', \$password\, \'test\')';
if (mysqli_query($con, $sql))
{
echo 'Done!';
}
else
{
echo 'No.';
}
mysqli_close($con);
The error
Connection worked!
Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\xampp\htdocs\hashing\password.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\hashing\password.php on line 3
Its just a simple PHP form that posts to the following PHP script. I have also got the SQL query formatted in phpMyAdmin. Thanks!