cancel
Showing results for 
Search instead for 
Did you mean: 

Cpanel MySQL Can't execute my insert query.

Hey guys, 
When I try to insert something into database the code won't Execute.
Something makes it so my query can't execute.
 
if ($mysqli = new mysqli($hostname, $username, $password, $dbname)) {
        echo "Connected To Database";
    } else {
        echo "Can't Connect To DataBase";
    }

 

        /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
        
    $query = $mysqli->stmt_init();

 

    if($query->prepare("INSERT INTO answers (answer01, answer02, answer03)
    VALUES (?, ?, ?)"))
    {
    echo("<br> Prepared!!!");
    
    $query->bind_param("iii",$category1, $category2, $category3);
    if ($query->execute())
    {
        echo "yay worked for once";
    } else {
        echo "can't execute again -.-";
    }
    $query->close();
    }
    else{
        echo("<br> Failed to Prepare");
    }
 
Someone know the problem?