When I build a query string using variables in PHP, it does not seem to be working. My current query is:
$u = "admin";
$hash = password_hash("password", PASSWORD_DEFAULT);
$set_login = "INSERT INTO users (username, password) VALUES ({$u}, {$hash})";
*I am executing the query further down in the script
If I replace {$u} with the string literal it represents, and replace {$hash} with just a string literal for a password, such as password, the query works fine. However, when I introduce variables that is when it breaks. I've tried breaking up the query string and using the concatenation operator:
$set_login = "INSERT INTO users (username, password) VALUES ( " . $u . ", " . $hash . ")";
This did not work either. I then thought it might be something with the hash, so I modified the code to (for testing):
$u = "admin";
$p = "password";
$set_login = "INSERT INTO users (username, password) VALUES ({$u}, {$p})";
This did not work either.
"INSERT INTO users (username, password) VALUES ('{$u}', '{$hash}')";