This function is primarily used to execute SQL statements and returns whether the operation was successful or not!
This function accepts five parameters; the first parameter sql The SQL statement to be executed; the last four parameters. db_host、db_user、db_password 和 db_name These parameters represent the MySQL database's hostname, username, password, and database name, respectively. The function returns a mysqli_result object representing the execution result; if the execution fails, it returns false.
Within the function, first create a MySQL database connection, then use it. query() Executes the specified SQL statement and stores the execution result in $result The variable is used. Finally, the function closes the MySQL database connection and returns the execution result.
Please note that since this function executes a specified SQL statement, you must ensure that the SQL statement provided is correct and does not cause any unintended impact on the database. For security reasons, it is recommended to validate and filter user-input SQL statements to prevent security vulnerabilities such as SQL injection.