Here's the code:
$coinno = $_POST["CoinNo"];
$week = $_POST["week"];
$payer = $_POST["payer"];
$payee = $_POST["payee"];
$servername = "localhost";
$username = "username"; // Edited from original
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO `Transactions`(`Week`,`Coin`,`Payer`,`Payee`)
VALUES ($week,$coinno,'$payer','$payee')";
if($conn->query(sql)===TRUE)
{
echo "Success";
}
else
{
echo "Error ".$sql."<br>".$conn->error;
}
$conn->close;
?>
And my error message:
Error INSERT INTO
Transactions
(Week
,Coin
,Payer
,Payee
) VALUE (1,2,'Bob','Carol') You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sql' at line 1
I've tried using backticks, single quotes, etc. Even copying the generated query from phpMyAdmin did not help.
Another notable issue is that my Transactions table has a single row but when I try to select it I get 0 results. Could there possibly be a connection?