-1

I am doing an insert on the MySQL table "analytics" with the fields "a_id" (PRIMARY and UNIQUE), "a_query" and "a_date".

My code:

function queryanalytics($clsendquery) {
     $datetime = date("Y-m-d H:i:s");
     $connection = connectsql();
     $sql = "INSERT INTO analytics (a_query,a_date) VALUES (?,?)";
     $stmt = $connection->prepare($sql);
     $stmt->bind_param('ss',$clsendquery,$datetime);
     $stmt->execute;
     $stmt->close();
 }

Nothing updates in the database and $stmt->affected_rows returns 0. There are no errors in $stmt->error or $connection->error. When I run the insert in phpMyAdmin it works fine.

I have other selects and inserts that work fine with the same connection, why does this one not? Please help me.

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39
Rohr
  • 17
  • 1
  • 6

1 Answers1

2

$stmt->execute; should be $stmt->execute();

Irvin
  • 830
  • 5
  • 13