0
このクエリはSQLインジェクションから安全ですか?このクエリはSQLインジェクションから安全ですか? [削除してください]
すべての関数で$ connection-> close();を書く必要があります。あなたの最初の質問に答えるために
function insert_mytable() {
global $connection;
$text = 'bla bla';
$hashtag = 'bla bla';
// Prepare the statement
$stmt = $connection->prepare("INSERT INTO my_table (text, hashtag) VALUES (?, ?)");
$stmt->bind_param('ss', $text, $hashtag);
// Execute the statement
$stmt->execute();
// Close the statement
$stmt->close();
$connection->close();
}
接続を閉じる必要はありません。すべてのクエリの後に接続を行うと反作用になります。 –
BTW ... '$ connection'は定義されていません。 – AbraCadaver