downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.mssql-select-db.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.mssql.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.mssql-select-db.php',
   
1 => 'mssql_select_db',
  ),
 
'up' =>
  array (
   
0 => 'ref.mssql.php',
   
1 => 'Mssql Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.mssql-rows-affected.php',
   
1 => 'mssql_rows_affected',
  ),
 
'next' =>
  array (
   
0 => 'book.mysql.php',
   
1 => 'MySQL',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.mssql-select-db" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mssql_select_db</h1>
  <p class="verinfo">(PHP 4, PHP 5, PECL odbtp &gt;= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_select_db</span> &mdash; <span class="dc-title">Select MS SQL database</span></p>

 </div>
 
 <a name="function.mssql-select-db.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>mssql_select_db</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$database_name</tt></span>
   [, <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$link_identifier</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   <b>mssql_select_db()</b> sets the current active
   database on the server that&#039;s associated with the specified link
   identifier. 
  </p>
  <p class="para">
   Every subsequent call to <a href="function.mssql-query.php" class="function">mssql_query()</a> will be
   made on the active database.
  </p>
 </div>


 <a name="function.mssql-select-db.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">database_name</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The database name.
      </p>
      <p class="para">
       To escape the name of a database that contains spaces, hyphens (&quot;-&quot;),
       or any other exceptional characters, the database name must be
       enclosed in brackets, as is shown in the example, below. This
       technique must also be applied when selecting a database name that is
       also a reserved word (such as <i>primary</i>).
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">link_identifier</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       A MS SQL link identifier, returned by
       <a href="function.mssql-connect.php" class="function">mssql_connect()</a> or
       <a href="function.mssql-pconnect.php" class="function">mssql_pconnect()</a>.
      </p>
      <p class="para">
       If no link identifier is specified, the last opened link is assumed.
       If no link is open, the function will try to establish a link as if
       <a href="function.mssql-connect.php" class="function">mssql_connect()</a> was called, and use it.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.mssql-select-db.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> on success or <b><tt class="constant">FALSE</tt></b> on failure.
  </p>
 </div>


 <a name="function.mssql-select-db.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>mssql_select_db()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;link&nbsp;to&nbsp;MSSQL<br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mssql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'KALLESPC\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sa'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Select&nbsp;the&nbsp;database&nbsp;'php'<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.mssql-select-db.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.mssql-connect.php" class="function" rel="rdfs-seeAlso">mssql_connect()</a> - Open MS SQL server connection</li>
    <li class="member"><a href="function.mssql-pconnect.php" class="function" rel="rdfs-seeAlso">mssql_pconnect()</a> - Open persistent MS SQL connection</li>
    <li class="member"><a href="function.mssql-query.php" class="function" rel="rdfs-seeAlso">mssql_query()</a> - Send MS SQL query</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites