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.";}
}
Use concatenation or double quotes.