Johny
Johny

Reputation: 21

Unable to create trigger in PHP for mySQL

I am trying to create a trigger into mySQL using PHP

mysqli_select_db($host, "game");
$sql = "CREATE TRIGGER test_seven BEFORE INSERT ON test FOR EACH ROW INSERT INTO test (name) VALUES ('test')";
$query = $host->prepare($sql);
$query->execute();

And it is not working even though I tried running it on phpMyAdmin and it worked.

EDIT: "This command is not supported in the prepared statement protocol yet" Is there a way of skipping the prepare statement then ?

Upvotes: 0

Views: 222

Answers (1)

Johny
Johny

Reputation: 21

Apparently the real problem was the fact that I was not supposed to use the PDO::prepare statement, if anyone else is having this issue use PDO::exec.

Upvotes: 1

Related Questions