Php/docs/function.dbx-escape-string

来自菜鸟教程
跳转至:导航、​搜索

dbx_escape_string

(PHP 4 >= 4.3.0, PHP 5 < 5.1.0, PECL dbx >= 1.1.0)

dbx_escape_string Escape a string so it can safely be used in an sql-statement


说明

dbx_escape_string ( object $link_identifier , string $text ) : string

Escape the given string so that it can safely be used in an sql-statement.


参数

link_identifier
The DBX link object returned by dbx_connect()
text
The string to escape.


返回值

Returns the text, escaped where necessary (such as quotes, backslashes etc). On error, null is returned.


范例

Example #1 dbx_escape_string() example

<?php$link   = dbx_connect(DBX_MYSQL, "localhost", "db", "username", "password")    or die("Could not connect");$text = dbx_escape_string($link, "It\'s quoted and backslashed (\\).");$result = dbx_query($link, "insert into tbl (txt) values ('" . $text . "')");if ($result == 0) {    echo dbx_error($link);}dbx_close($link);?>

参见

  • dbx_query() - Send a query and fetch all results (if any)