How do I insert PHP variables in a MySQL table? : <p>I have the following code that should create a table and populate it with two users. The create table query works, but the insert does not. Any help would be appreciated.</p>

<pre><code>    &lt;?php 
    require_once 'login12.php';
    $link = mysqli_connect($db_hostname, $db_username, $db_password);
    if (!$link) die ("Unable to connect to MySQL: " .mysqli_error());
    mysqli_select_db($link, $db_database) or die("Unable to select database: "     .mysqli_error());
$query = "CREATE TABLE `users` (
         forename VARCHAR(32) NOT NULL,
         surname VARCHAR(32) NOT NULL,
         username VARCHAR(32) NOT NULL UNIQUE,
         password VARCHAR(32) NOT NULL)";
$result = mysqli_query($link, $query);
if (!$result) die ("Database access failed: " .mysqli_error());
$salt1 = 'G3tD0wnonIT!';
$salt2 = 'Y0uwant2';
$forename = 'Bill';
$surname = 'Smith';
$username = 'bsmith';
$password = 'mysecret';
$token = sha1("$salt2$password$salt1");
add_user($forename, $surname, $username, $token);
$forename = 'Pauline';
$surname = 'Jones';
$username = 'pjones';
$password = 'acrobat';
$token = sha1("$salt2$password$salt1");
add_user($forename, $surname, $username, $token);
function add_user($fn, $sn, $un, $pw) {
    $query = "INSERT INTO `users` (`forename`, `surname`, `username`, `password`) VALUES ('$fn', '$sn', '$un', '$pw')";
    $result = mysqli_query($link, $query);
    if (!$result) die ("Database access failed: " .mysqli_error());
}
?&gt;
</code></pre>
