Mysqli insert statement

I went through this a couple of days and I just canโ€™t find the cause of the error. I do not get a php warning, just the "somethign went wrong" error handler instead of embedding. I know that the lovely young guys here are likely to notice this in a few seconds, for example, considering it is just an insertion expression, 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.";} } 
+6
source share
1 answer

ok i echoed stmt error and he told me that $ resultsTable does not exist. In core.inc, I have a definition for this 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,?,?,?,?,?,?,?)"; 
+3
source

Source: https://habr.com/ru/post/913795/


All Articles