hey i have a problem with inserting some data in my database:
define('SECURE', true);
include "storescripts/connect_to_mysql.php";
$txn_id = 123456789101234567;
$payer_email = "irgendwas@gmx.de";
$mc_gross = "amount";
$sql = "SELECT COUNT(*) AS count FROM `trans` WHERE `txn_id` = $txn_id";
$q = mysqli_query($mysqli, $sql);
$f = mysqli_fetch_array($q);
if($f['count'] > 0) {
echo "Transaction already processed";
} else {
$insert = mysqli_query($mysqli, "INSERT INTO trans (`txn_id`, `payer_email`,`mc_gross`)
VALUES ($txn_id,$payer_email,$mc_gross)");
if($insert = 1) {
echo "inserted";
} else {
echo "not inserted";
}
}
As a result i get: "inserted", but i have no data in my database..anyone can help me? where is the bug?
edit: this is my table:
define('SECURE', true);
require "connect_to_mysql.php";
$sqlCommand = "CREATE TABLE trans (
id int(11) NOT NULL auto_increment,
txn_id varchar(255) NOT NULL,
payer_email varchar(255) NOT NULL,
mc_gross int(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (txn_id))";
if ($mysqli->query($sqlCommand)) {
echo "Your trans table has been created successfully!";
} else {
echo "CRITICAL ERROR;".$mysqli->error;
}