Ive been going over this for a couple days and i just cant find the reason it is erroring out. Im not getting a php warning, just the error handler "somethign went wrong" instead of inserting. I know the fine young lads here will probably spot it in a few seconds, esp considering its just a simple insert statement, but im buggered. Thanks in advance.
include('core.inc.php');
$sql = 'INSERT INTO $resultsTable (
id,
firstName,
lastName,
email,
birthday,
anniversary,
location,
campaign
)
VALUES (NULL,?,?,?,?,?,?,?)';
$stmt = $mysql->stmt_init();
if ($stmt->prepare($sql)) {
// bind parameters and execute statement
$stmt->bind_param(
'sssssss',
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['birthday'],
$_POST['anniversary'],
$_POST['location'],
$campaign
);
$OK = $stmt->execute();}
// return if successful or display error
if ($OK) {$response = "Success";}
else {$response ="Something went wrong.";}
}
ok i echoed stmt error and it told me that $resultsTable didnt exist. In core.inc, I have a definition for that variable
Use concatenation or double quotes.
$sql = 'INSERT INTO ' . $resultsTable . ' (
id,
firstName,
lastName,
email,
birthday,
anniversary,
location,
campaign
)
VALUES (NULL,?,?,?,?,?,?,?)';
$sql = "INSERT INTO $resultsTable (
id,
firstName,
lastName,
email,
birthday,
anniversary,
location,
campaign
)
VALUES (NULL,?,?,?,?,?,?,?)";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With