I'm creating a WordPress plugin and I need to update some information using a variable in the query. I need a way to find the current database name and store it in a variable so that way the query works no matter what your database is named.
UPDATE
This is the code I'm using now. echo and print_r result in the string I want. But it's still giving me the bind_param
error.
$database_name = DB_NAME;
echo "$database_name </br>";
$database_name = mysqli_real_escape_string($conn, $database_name);
print_r($database_name);
$stmt = $conn->prepare("UPDATE ? . `wp_users` SET `user_pass` = ? WHERE `user_login` = ?") or trigger_error($mysqli->error);
$stmt->bind_param('sss', $database_name, $user_password[$i], $user_login[$i]);
It keeps bringing up an error that says
Fatal error: Call to a member function bind_param() on boolean
The $current_database
variable is what's causing the error. But I thought I've syntactically done everything right. I looked up ways to do this on this site and the php docs, but none of it is working. I'm thinking I must be missing something fairly simple. Any help is greatly appreciated.