in Deutsh
in French
in Polish

You Are At Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

mysqli_stmt_bind_param

(PHP 5)

mysqli_stmt_bind_param

(no version information, might be only in CVS)

stmt->bind_param() -- Binds variables to a prepared statement as parameters

Description

Procedural style:

bool mysqli_stmt_bind_param ( mysqli_stmt stmt, string types, mixed &var1 [, mixed &...] )

Object oriented style (method):

class mysqli_stmt {

bool bind_param ( string types, mixed &var1 [, mixed &...] )

}

Bind variables for the parameter markers in the SQL statement that was passed to mysqli_prepare().

Note: If data size of a variable exceeds max. allowed packet size (max_allowed_packet), you have to specify b in types and use mysqli_stmt_send_long_data() to send the data in packets.

Parameters

stmt

Procedural style only: A statement identifier returned by mysqli_stmt_init().

types

A string that contains one or more characters which specify the types for the corresponding bind variables:

Table 1. Type specification chars

CharacterDescription
icorresponding variable has type integer
dcorresponding variable has type double
scorresponding variable has type string
bcorresponding variable is a blob and will be sent in packets

var1

The number of variables and length of string types must match the parameters in the statement.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example 1. Object oriented style

<?php
$mysqli
= new mysqli('localhost', 'my_user', 'my_password', 'world');

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
$stmt->bind_param('sssd', $code, $language, $official, $percent);

$code = 'DEU';
$language = 'Bavarian';
$official = "F";
$percent = 11.2;

/* execute prepared statement */
$stmt->execute();

printf("%d Row inserted.\n", $stmt->affected_rows);

/* close statement and connection */
$stmt->close();

/* Clean up table CountryLanguage */
$mysqli->query("DELETE FROM CountryLanguage WHERE Language='Bavarian'");
printf("%d Row deleted.\n", $mysqli->affected_rows);

/* close connection */
$mysqli->close();
?>

Example 2. Procedural style

<?php
$link
= mysqli_connect('localhost', 'my_user', 'my_password', 'world');

/* check connection */
if (!$link) {
    
printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

$stmt = mysqli_prepare($link, "INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
mysqli_stmt_bind_param($stmt, 'sssd', $code, $language, $official, $percent);

$code = 'DEU';
$language = 'Bavarian';
$official = "F";
$percent = 11.2;

/* execute prepared statement */
mysqli_stmt_execute($stmt);

printf("%d Row inserted.\n", mysqli_stmt_affected_rows($stmt));

/* close statement and connection */
mysqli_stmt_close($stmt);

/* Clean up table CountryLanguage */
mysqli_query($link, "DELETE FROM CountryLanguage WHERE Language='Bavarian'");
printf("%d Row deleted.\n", mysqli_affected_rows($link));

/* close connection */
mysqli_close($link);
?>

The above example will output:

1 Row inserted.
1 Row deleted.

See Also

mysqli_stmt_bind_result()
mysqli_stmt_execute()
mysqli_stmt_fetch()
mysqli_prepare()
mysqli_stmt_send_long_data()
mysqli_stmt_errno()
mysqli_stmt_error()

szkolenia zawodowe kursy zawodowe przygotowanie do zawodu
Crm dedykowany
najlepsza strona blogs o UKS profesjonalne wyniki
Skuteczne pozycjonowanie stron łódź i cała Polska.
przetargi Adamówka

Another Useful functions:


ref.pdo-mysql | ref.pdo-mysql.connection | ref.mysqli | ref.mysql | function.mysqli-warning-count | function.mysqli-use-result | function.mysqli-thread-safe | function.mysqli-thread-id | function.mysqli-store-result | function.mysqli-stmt-store-result | function.mysqli-stmt-sqlstate | function.mysqli-stmt-send-long-data | function.mysqli-stmt-result-metadata | function.mysqli-stmt-reset | function.mysqli-stmt-prepare | function.mysqli-stmt-param-count | function.mysqli-stmt-num-rows | function.mysqli-stmt-insert-id | function.mysqli-stmt-init | function.mysqli-stmt-get-warnings | function.mysqli-stmt-free-result | function.mysqli-stmt-field-count | function.mysqli-stmt-fetch | function.mysqli-stmt-execute | function.mysqli-stmt-error | function.mysqli-stmt-errno | function.mysqli-stmt-data-seek | function.mysqli-stmt-close | function.mysqli-stmt-bind-result | function.mysqli-stmt-bind-param | function.mysqli-stmt-attr-set | function.mysqli-stmt-attr-get | function.mysqli-stmt-affected-rows | function.mysqli-stat | function.mysqli-ssl-set | function.mysqli-sqlstate | function.mysqli-slave-query | function.mysqli-set-opt | function.mysqli-set-local-infile-handler | function.mysqli-set-local-infile-default | function.mysqli-set-charset | function.mysqli-server-init | function.mysqli-server-end | function.mysqli-send-query | function.mysqli-send-long-data | function.mysqli-select-db | function.mysqli-rpl-query-type | function.mysqli-rpl-probe | function.mysqli-rpl-parse-enabled | function.mysqli-rollback | function.mysqli-report | function.mysqli-real-query | function.mysqli-real-escape-string | function.mysqli-real-connect | function.mysqli-query | function.mysqli-prepare | function.mysqli-ping | function.mysqli-param-count | function.mysqli-options | function.mysqli-num-rows | function.mysqli-num-fields | function.mysqli-next-result | function.mysqli-multi-query | function.mysqli-more-results | function.mysqli-master-query | function.mysqli-kill | function.mysqli-insert-id | function.mysqli-init | function.mysqli-info | function.mysqli-get-warnings | function.mysqli-get-server-version | function.mysqli-get-server-info | function.mysqli-get-proto-info | function.mysqli-get-metadata | function.mysqli-get-host-info | function.mysqli-get-client-version | function.mysqli-get-client-info | function.mysqli-get-charset | function.mysqli-free-result | function.mysqli-field-tell | function.mysqli-field-seek | function.mysqli-field-count | function.mysqli-fetch | function.mysqli-fetch-row | function.mysqli-fetch-object | function.mysqli-fetch-lengths | function.mysqli-fetch-fields | function.mysqli-fetch-field | function.mysqli-fetch-field-direct | function.mysqli-fetch-assoc | function.mysqli-fetch-array | function.mysqli-execute | function.mysqli-escape-string | function.mysqli-error | function.mysqli-errno | function.mysqli-enable-rpl-parse | function.mysqli-enable-reads-from-master | function.mysqli-embedded-server-start | function.mysqli-embedded-server-end | function.mysqli-dump-debug-info | function.mysqli-disable-rpl-parse | function.mysqli-disable-reads-from-master | function.mysqli-debug | function.mysqli-data-seek | function.mysqli-connect | function.mysqli-connect-error | function.mysqli-connect-errno | function.mysqli-commit | function.mysqli-close | function.mysqli-client-encoding | function.mysqli-character-set-name | function.mysqli-change-user | function.mysqli-bind-result | function.mysqli-bind-param | function.mysqli-autocommit | function.mysqli-affected-rows | function.mysql-unbuffered-query | function.mysql-thread-id | function.mysql-tablename | function.mysql-stat | function.mysql-select-db | function.mysql-result | function.mysql-real-escape-string | function.mysql-query | function.mysql-ping | function.mysql-pconnect | function.mysql-num-rows | function.mysql-num-fields | function.mysql-list-tables | function.mysql-list-processes | function.mysql-list-fields | function.mysql-list-dbs | function.mysql-insert-id | function.mysql-info | function.mysql-get-server-info | function.mysql-get-proto-info | function.mysql-get-host-info | function.mysql-get-client-info | function.mysql-free-result | function.mysql-field-type | function.mysql-field-table | function.mysql-field-seek | function.mysql-field-name | function.mysql-field-len | function.mysql-field-flags | function.mysql-fetch-row | function.mysql-fetch-object | function.mysql-fetch-lengths | function.mysql-fetch-field | function.mysql-fetch-assoc | function.mysql-fetch-array | function.mysql-escape-string | function.mysql-error | function.mysql-errno | function.mysql-drop-db | function.mysql-db-query | function.mysql-db-name | function.mysql-data-seek | function.mysql-create-db | function.mysql-connect | function.mysql-close | function.mysql-client-encoding | function.mysql-change-user | function.mysql-affected-rows |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.