Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4886

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Escapes a string for use in a mysql_query</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-error.html">mysql_error</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-fetch-array.html">mysql_fetch_array</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mysql-escape-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_escape_string</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_escape_string</span> &mdash; <span class="dc-title">Escapes a string for use in a mysql_query</span></p>

 </div>

 <div id="function.mysql-escape-string-refsynopsisdiv">
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">This function was deprecated in PHP 4.3.0, and it
and the entire <a href="book.mysql.html" class="link">original MySQL extension</a> was removed in PHP 7.0.0.
Instead, use either the actively developed <a href="book.mysqli.html" class="link">MySQLi</a> or <a href="ref.pdo-mysql.html" class="link">PDO_MySQL</a> extensions.
See also the <a href="mysqlinfo.api.choosing.html" class="link">MySQL: choosing an API</a> guide and its
<a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">related FAQ entry</a> for additional information. 
Alternatives to this function include:</p>
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.mysqli-escape-string.html" class="function">mysqli_escape_string()</a></span></li>
    <li class="member"><span class="methodname"><a href="pdo.quote.html" class="methodname">PDO::quote()</a></span></li>
   </ul>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.mysql-escape-string-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>mysql_escape_string</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$unescaped_string</code></span>
   )</div>

  <p class="para rdfs-comment">
   This function will escape the <code class="parameter">unescaped_string</code>,
   so that it is safe to place it in a <span class="function"><a href="function.mysql-query.html" class="function">mysql_query()</a></span>.
   This function is deprecated.
  </p>
  <p class="para">
   This function is identical to <span class="function"><a href="function.mysql-real-escape-string.html" class="function">mysql_real_escape_string()</a></span> 
   except that <span class="function"><a href="function.mysql-real-escape-string.html" class="function">mysql_real_escape_string()</a></span> takes a 
   connection handler and escapes the string according to the current 
   character set. <span class="function"><strong>mysql_escape_string()</strong></span> does not take a
   connection argument and does not respect the current charset setting.  
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-escape-string-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">unescaped_string</code></dt>

     <dd>

      <p class="para">
       The string that is to be escaped.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.mysql-escape-string-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the escaped string.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mysql-escape-string-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        This function now throws an E_DEPRECATED notice.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        This function became deprecated, do not use this function. Instead, 
        use <span class="function"><a href="function.mysql-real-escape-string.html" class="function">mysql_real_escape_string()</a></span>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysql-escape-string-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2179">
    <p><strong>Example #1 <span class="function"><strong>mysql_escape_string()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$item&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Zak's&nbsp;Laptop"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$escaped_item&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$item</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"Escaped&nbsp;string:&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$escaped_item</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Escaped string: Zak\&#039;s Laptop
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.mysql-escape-string-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    <span class="function"><strong>mysql_escape_string()</strong></span> does not escape
    <em>%</em> and <em>_</em>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-escape-string-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.mysql-real-escape-string.html" class="function" rel="rdfs-seeAlso">mysql_real_escape_string()</a> - Escapes special characters in a string for use in an SQL statement</span></li>
    <li class="member"><span class="function"><a href="function.addslashes.html" class="function" rel="rdfs-seeAlso">addslashes()</a> - Quote string with slashes</span></li>
    <li class="member">The <a href="info.configuration.html#ini.magic-quotes-gpc" class="link">magic_quotes_gpc</a> directive.</li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-error.html">mysql_error</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-fetch-array.html">mysql_fetch_array</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>