<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >sqlite_escape_string</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="SQLite" HREF="ref.sqlite.html"><LINK REL="PREVIOUS" TITLE="sqlite_error_string" HREF="function.sqlite-error-string.html"><LINK REL="NEXT" TITLE="sqlite_exec" HREF="function.sqlite-exec.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-2"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.sqlite-error-string.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.sqlite-exec.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.sqlite-escape-string" ></A >sqlite_escape_string</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN105332" ></A ><P > (PHP 5)</P >sqlite_escape_string -- Escapes a string for use as a query parameter</DIV ><DIV CLASS="refsect1" ><A NAME="AEN105335" ></A ><H2 >Description</H2 >string <B CLASS="methodname" >sqlite_escape_string</B > ( string item)<BR ></BR ><P > <B CLASS="function" >sqlite_escape_string()</B > will correctly quote the string specified by <VAR CLASS="parameter" >item</VAR > for use in an SQLite SQL statement. This includes doubling up single-quote characters (<VAR CLASS="literal" >'</VAR >) and checking for binary-unsafe characters in the query string. </P ><P > If the <VAR CLASS="parameter" >item</VAR > contains a <VAR CLASS="literal" >NUL</VAR > character, or if it begins with a character whose ordinal value is <VAR CLASS="literal" >0x01</VAR >, PHP will apply a binary encoding scheme so that you can safely store and retrieve binary data. </P ><P > Although the encoding makes it safe to insert the data, it will render simple text comparisons and <VAR CLASS="literal" >LIKE</VAR > clauses in your queries unusable for the columns that contain the binary data. In practice, this shouldn't be a problem, as your schema should be such that you don't use such things on binary columns (in fact, it might be better to store binary data using other means, such as in files). </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Avertisment</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > <A HREF="function.addslashes.html" ><B CLASS="function" >addslashes()</B ></A > should <SPAN CLASS="emphasis" ><I CLASS="emphasis" >NOT</I ></SPAN > be used to quote your strings for SQLite queries; it will lead to strange results when retrieving your data. </P ></TD ></TR ></TABLE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > Do not use this function to encode the return values from UDF's created using <A HREF="function.sqlite-create-function.html" ><B CLASS="function" >sqlite_create_function()</B ></A > or <A HREF="function.sqlite-create-aggregate.html" ><B CLASS="function" >sqlite_create_aggregate()</B ></A > - use <A HREF="function.sqlite-udf-encode-binary.html" ><B CLASS="function" >sqlite_udf_encode_binary()</B ></A > instead. </P ></BLOCKQUOTE ></DIV ><P > See also <A HREF="function.sqlite-udf-encode-binary.html" ><B CLASS="function" >sqlite_udf_encode_binary()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.sqlite-error-string.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.sqlite-exec.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >sqlite_error_string</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.sqlite.html" ACCESSKEY="U" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >sqlite_exec</TD ></TR ></TABLE ></DIV ></BODY ></HTML >