<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'function.mysql-query.php',
    1 => 'mysql_query',
    2 => 'Send a MySQL query',
  ),
  'up' => 
  array (
    0 => 'ref.mysql.php',
    1 => 'MySQL İşlevleri',
  ),
  'prev' => 
  array (
    0 => 'function.mysql-ping.php',
    1 => 'mysql_ping',
  ),
  'next' => 
  array (
    0 => 'function.mysql-real-escape-string.php',
    1 => 'mysql_real_escape_string',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mysql/functions/mysql-query.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mysql-query" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_query</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_query</span> &mdash; <span class="dc-title">Send a MySQL query</span></p>

 </div>

 <div id="function.mysql-query-refsynopsisdiv">
  <div class="warning"><strong class="warning">Uyarı</strong>
   <p class="para">
Bu eklentinin kullanımı PHP 5.5.0 itibariyle önerilmemekte olup
PHP 7.0.0&#039;da kaldırılmıştır. Bu eklentinin yerine ya
<a href="book.mysqli.php" class="link">mysqli</a> ya da
<a href="ref.pdo-mysql.php" class="link">PDO_MySQL</a> eklentisi kullanılmalıdır.
MySQL API seçerken <a href="mysqlinfo.api.choosing.php" class="link">MySQL API&#039;ye
Bakış</a> belgesi yardımcı olabilir. Bu işlevin yerine
kullanılabilecekler:</p>
   <ul class="simplelist">
    <li><span class="function"><a href="mysqli.query.php" class="function">mysqli_query()</a></span></li>
    <li><span class="methodname"><a href="pdo.query.php" class="methodname">PDO::query()</a></span></li>
   </ul>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.mysql-query-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mysql_query</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$query</code></span>, <span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$link_identifier</code><span class="initializer"> = NULL</span></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="simpara">
   <span class="function"><strong>mysql_query()</strong></span> sends a unique query (multiple queries
   are not supported) to the currently
   active database on the server that&#039;s associated with the
   specified <code class="parameter">link_identifier</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-query-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <dl>
   
    <dt><code class="parameter">query</code></dt>
    <dd>
     <span class="simpara">
      An SQL query
     </span>
     <span class="simpara">
      The query string should not end with a semicolon.
      Data inside the query should be <a href="function.mysql-real-escape-string.php" class="link">properly escaped</a>.
     </span>
    </dd>
   
   
<dt><code class="parameter">bağlantı_belirteci</code></dt>
<dd><p class="para">MySQL bağlantısı. Eğer bağlantı belirteci belirtilmemişse
<span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span> tarafından açılan son bağlantı
kullanılmaya çalışılır. Eğer böyle bir bağlantı yoksa
<span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span> bağımsız değişkensiz olarak çağrılmış gibi bir
bağlantı oluşturmaya çalışır. Hiçbir bağlantı yoksa ve yenisi de
kurulamazsa  <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> seviyesinde bir hata
üretilir.</p></dd>
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysql-query-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="simpara">
   For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset,
   <span class="function"><strong>mysql_query()</strong></span>
   returns a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> on success, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on
   error.
  </p>
  <p class="simpara">
   For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc,
   <span class="function"><strong>mysql_query()</strong></span> returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success
   or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on error.
  </p>
  <p class="simpara">
   The returned result resource should be passed to
   <span class="function"><a href="function.mysql-fetch-array.php" class="function">mysql_fetch_array()</a></span>, and other
   functions for dealing with result tables, to access the returned data.
  </p>
  <p class="simpara">
   Use <span class="function"><a href="function.mysql-num-rows.php" class="function">mysql_num_rows()</a></span> to find out how many rows
   were returned for a SELECT statement or
   <span class="function"><a href="function.mysql-affected-rows.php" class="function">mysql_affected_rows()</a></span> to find out how many
   rows were affected by a DELETE, INSERT, REPLACE, or UPDATE
   statement.
  </p>
  <p class="simpara">
   <span class="function"><strong>mysql_query()</strong></span> will also fail and return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
   if the user does not have permission to access the table(s) referenced by
   the query.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mysql-query-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="example-1">
   <p><strong>Örnek 1 Invalid Query</strong></p>
   <div class="example-contents"><p>
    The following query is syntactically invalid, so
    <span class="function"><strong>mysql_query()</strong></span> fails and returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$result </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT * WHERE 1=1'</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br />    die(</span><span style="color: #DD0000">'Invalid query: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">());<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Örnek 2 Valid Query</strong></p>
   <div class="example-contents"><p>
    The following query is valid, so <span class="function"><strong>mysql_query()</strong></span>
    returns a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// This could be supplied by a user, for example<br /></span><span style="color: #0000BB">$firstname </span><span style="color: #007700">= </span><span style="color: #DD0000">'fred'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$lastname  </span><span style="color: #007700">= </span><span style="color: #DD0000">'fox'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Formulate Query<br />// This is the best way to perform an SQL query<br />// For more examples, see mysql_real_escape_string()<br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT firstname, lastname, address, age FROM friends<br />    WHERE firstname='%s' AND lastname='%s'"</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">mysql_real_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$firstname</span><span style="color: #007700">),<br />    </span><span style="color: #0000BB">mysql_real_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$lastname</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// Perform Query<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Check result<br />// This shows the actual query sent to MySQL, and the error. Useful for debugging.<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">$result</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$message  </span><span style="color: #007700">= </span><span style="color: #DD0000">'Invalid query: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">mysql_error</span><span style="color: #007700">() . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$message </span><span style="color: #007700">.= </span><span style="color: #DD0000">'Whole query: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$query</span><span style="color: #007700">;<br />    die(</span><span style="color: #0000BB">$message</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Use result<br />// Attempting to print $result won't allow access to information in the resource<br />// One of the mysql result functions must be used<br />// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.<br /></span><span style="color: #007700">while (</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'firstname'</span><span style="color: #007700">];<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">];<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'address'</span><span style="color: #007700">];<br />    echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'age'</span><span style="color: #007700">];<br />}<br /><br /></span><span style="color: #FF8000">// Free the resources associated with the result set<br />// This is done automatically at the end of the script<br /></span><span style="color: #0000BB">mysql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-query-seealso">
  <h3 class="title">Ayrıca Bakınız</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.mysql-connect.php" class="function" rel="rdfs-seeAlso">mysql_connect()</a> - MySQL Sunucusuna bir bağlantı a&ccedil;ar</span></li>
   <li><span class="function"><a href="function.mysql-error.php" class="function" rel="rdfs-seeAlso">mysql_error()</a> - Returns the text of the error message from previous MySQL operation</span></li>
   <li><span class="function"><a href="function.mysql-real-escape-string.php" 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><span class="function"><a href="function.mysql-result.php" class="function" rel="rdfs-seeAlso">mysql_result()</a> - Get result data</span></li>
   <li><span class="function"><a href="function.mysql-fetch-assoc.php" class="function" rel="rdfs-seeAlso">mysql_fetch_assoc()</a> - Fetch a result row as an associative array</span></li>
   <li><span class="function"><a href="function.mysql-unbuffered-query.php" class="function" rel="rdfs-seeAlso">mysql_unbuffered_query()</a> - Sonu&ccedil; k&uuml;mesi tamponlanmayan ve alınmayan bir SQL sorgusu
  g&ouml;nderir</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>