So I have built this function to do a search of the database/table specified to return if it exists or not.
function dataSearch($table, $date, $team, $record, $storeId){
global $conn;
$sql = $conn->prepare("SELECT entryId, date FROM ? WHERE date = ? && storeId = ? && record = ? LIMIT 1");
$sql->bind_param("ssss", $table, $date, $storeId, $record);
$sql->execute();
$result = $sql->get_result();
$result = $result->fetch_assoc();
if ($date === $result["date"]) {
echo "Skipping Entry, Data Already Exists in Database";
} else {
***Input Data***
The issue I am running into is with the line:
$sql->bind_param("ssss", $table, $date, $storeId, $record);
And every time I run the code I get this error:
PHP Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in /var/www/html/engine6.0.php:25
Which is weird because all of the variables I am passing are strings, not booleans…
I feel like I am missing something that is fairly obvious, or just taking an odd approach that has a better option. Anyways, any help would be greatly appreciated! And thank you in advance!