---
name: "mysql_stmt_init"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_stmt_init"
---

# mysql\_stmt\_init(3)

### Name

mysql\_stmt\_init - Initializes a prepared statement handle

### Synopsis

-

  ```
  #include <mysql.h>
  MYSQL_STMT * mysql_stmt_init(MYSQL * mysql);
  ```

### Description

Initializes and allocates memory for a prepared statement.

### Parameter

- •

  `mysql` - a mysql handle, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**.

### Return value

Returns a pointer to a `MYSQL_STMT` structure or `NULL` if an error occurred.

### Notes

- •

  Members of the `MYSQL_STMT` structure are not intended for application use.

- •

  A statement handle which was allocated by mysql\_stmt\_init() needs to be freed with **[mysql\_stmt\_close(3)](/mysql_stmt_close/3.md)**.

- •

  Any subsequent calls to any mysql\_stmt function will fail until **[mysql\_stmt\_prepare(3)](/mysql_stmt_prepare/3.md)** was called.

### See Also

- •

  **[mysql\_stmt\_close(3)](/mysql_stmt_close/3.md)**

- •

  **[mysql\_stmt\_prepare(3)](/mysql_stmt_prepare/3.md)**
