1

I'm relatively new to PHP and SQL and I keep getting this error popping up.

Fatal error: Uncaught mysqli_sql_exception: Table 'spa-francorchamps.message' doesn't exist in C:\xampp\htdocs\spa_francorchamps\process-form.php:23 Stack trace: #0 C:\xampp\htdocs\spa_francorchamps\process-form.php(23): mysqli_stmt_prepare(Object(mysqli_stmt), 'INSERT INTO mes...') #1 {main} thrown in C:\xampp\htdocs\spa_francorchamps\process-form.php on line 23

Here is my PHP code

<?php

$name = $_POST["name"];
$email = $_POST["email"];
$query = $_POST["query"];

$host = "localhost";
$dbname = "spa-francorchamps";
$username = "root";
$password = "";

$conn = mysqli_connect($host, $username, $password, $dbname);

if (mysqli_connect_errno()) {
    die("connection error: " . mysqli_connect_error());
}

$sql = "INSERT INTO message (name, email, query)
        VALUES (?, ?, ?)";

$stmt = mysqli_stmt_init($conn);

if ( ! mysqli_stmt_prepare($stmt, $sql)) {
    die(mysqli_error($conn));
}

mysqli_stmt_bind_param($stmt, "sss", $name, $email, $query);

mysqli_stmt_excecute($stmt);

echo "Record saved.";

I checked the connection to my database earlier on in my code and it connected successfully so I am unsure of what to do.

Thanks in advance for your help

user3783243
  • 5,368
  • 5
  • 22
  • 41
Hyperion
  • 11
  • 2
  • This is the literal code? – user3783243 Oct 28 '22 at 09:47
  • 1
    As a general tip, there's a much better, simpler, more secure and more reliable way to handle errors in your mysqli code - see [mysqli or die, does it have to die?](https://stackoverflow.com/questions/15318368/mysqli-or-die-does-it-have-to-die) – ADyson Oct 28 '22 at 10:00

0 Answers0