PHP MySQLi Query Not Working
<p>I am attempting to insert data into my users table in my database whenever a user signs up, however, I am having trouble doing so.. </p>

<p>I attempted to do it on my index.php file (which worked perfectly) as a test:</p>

<pre><code>if(empty($_POST['post'])) {
    mysqli_query($conn,"INSERT INTO users (fname,lname,group) VALUES ('John','Doe',1)");
}
</code></pre>

<p>I then attempted to do it in my register form, which didn't work so well, and I am trying to figure out why... </p>

<p>Here is the register function in the "users.php" file:</p>

<pre><code>function register_user($register_data) {
    array_walk($register_data, 'array_sanitize');
    $register_data['password'] = md5($register_data['password']);

    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';

    mysqli_query($conn, "INSERT INTO users ($fields) VALUES ($data)");
}
</code></pre>

<p>And the code I used on the "register.php" page:</p>

<pre><code>require_once 'core/init.php';

$conn = new mysqli($host, $user, $pass, $_db);

if(empty($_POST) === false) {
    $register_data = array(
        'username'   =&gt; $_POST['username'],
        'password'   =&gt; $_POST['password'],
        'fname'      =&gt; $_POST['fname'],
        'lname'      =&gt; $_POST['lname'],
        'email'      =&gt; $_POST['email']
    );
    register_user($register_data);
    header('location: register.php?success');
    exit();
}
</code></pre>

<p>And finally, my Initialization file "init.php":</p>

<pre><code>session_start();
    //error_reporting(0);

    require '_db/connect.php';
    require '_users/general.php';
    require '_users/users.php'; 
</code></pre>

<p>Note that inside of my "connect.php" file is the database connection script:</p>

<pre><code>$host = "127.0.0.1";
$user = "root";
$pass = "";
$_db = "test";

//connect script
$conn = new mysqli($host, $user, $pass, $_db);
</code></pre>

<p>Any and all help is appreciated!</p>

<p>Thanks!</p>