The issue I am having appears to be an error with the way i'm creating my prepared sql statement to insert some data. My first thought was that something was null, but I know the data is there because i've tested it with an echo. My thought is it has to be with the way the statement is written but I can't figure out what could be wrong with it.
Code:
// Set up the sql command
$stmt = $mysqli->prepare("INSERT INTO tblcomments (imgpath, author, comment) VALUES(?, ?, ?)");
// Bind the data
$stmt->bind_param("imgpath", $imagePath);
$stmt->bind_param("author", $author);
$stmt->bind_param("comment", $comment);
// Execute the sql
$stmt->execute();
// Close the statement
$stmt->close();
The issue is the insert statement itself, at least according to the error, which is:
Fatal error: Uncaught Error: Call to a member function prepare() on null in D:\Inetpub\vhosts\kreativecoating.com\httpdocs\commentDataPostHandler.php:55 Stack trace: #0 {main} thrown in D:\Inetpub\vhosts\kreativecoating.com\httpdocs\commentDataPostHandler.php on line 55
Line 55 being the one with the insert statement. So my question is am I doing something wrong with the prepared statement? I've checked the database fields for typing errors so it isn't that. There is an id field not listed in the sql but thats the key and auto increments, so it shouldn't need to be there