PHP mysqli_prepare() Function

Object oriented style

mysqli_stmt mysqli::prepare ( string $query )

Procedural style

mysqli_stmt mysqli_prepare ( mysqli $link , string $query )

Prepares the SQL query, and returns a statement handle to be used for further operations on the statement. The query must consist of a single SQL statement.

The parameter markers must be bound to application variables using mysqli_stmt_bind_param() and/or mysqli_stmt_bind_result() before executing the statement or fetching rows.

Examples -

Object oriented style

Procedural style

Amersfoort is in district Utrecht

ParameterDescription
linkProcedural style only: A link identifier returned by mysqli_connect() or mysqli_init()
queryThe query, as a string.

Return Values

mysqli_prepare() returns a statement object or FALSE if an error occurred.