title: Executing a simple SQL Server stored procedure from php
body: <p>First of all: I did a research on google and stackoverflow, but it does not helped me.</p>
  
  <p>I'm a beginner, so please do not blame me directly by just reading the title and voting me down. Stackoverflow seems to be <strong>very</strong> aggressive sometimes :(</p>
  
  <p>I'm trying to execute a simple stored procedure from PHP.
  Connecting to the database works.</p>
  
  <p>This code also works through a query in SQL Server Management Studio:</p>
  
  <pre><code>Execute SP_TPL_DeleteUser
  @ExternalFieldID = 22
  </code></pre>
  
  <p>Regarding to this manuals: <a href="http://www.sweeting.org/mark/blog/2005/02/24/php-stored-procedures-and-sql-server" rel="nofollow">PHP Stored Procedures and SQL Server</a> and <a href="http://php.net/manual/en/function.mssql-bind.php" rel="nofollow">MSSQL Bind</a> </p>
  
  <p>I build this lines of code:</p>
  
  <pre><code>$id=22;
  $stmt=mssql_init("SP_TPL_DeleteUser", $conn);
  mssql_bind($stmt, "@ExternalFieldID", $ExternalFieldID, SQLVARCHAR, false, false, 255);
  mssql_execute($stmt);
  mssql_free_statement($stmt);
  </code></pre>
  
  <p>My output is:</p>
  
  <blockquote>
    <p>( ! ) Fatal error: Call to undefined function mssql_init() in
    C:\Users\kians_000\dev\traka\index.php on line 32</p>
  </blockquote>
  
  <p>Of course I tried playing around, but nothing works :(
  I would be thankful for any tips.</p>
  
  <p>Edit:</p>
  
  <p>I can connect to the DB with this:</p>
  
  <pre><code>$serverName = "KIAN-PC";
  $connectionInfo = array( "Database"=&gt;"T32Database");
  $conn = sqlsrv_connect( $serverName, $connectionInfo);
  
  if( $conn )
  {
      echo "Connection established.\n";
  }
  else
  {
      echo "Connection could not be established.\n";
      die( print_r( sqlsrv_errors(), true));
  }
  </code></pre>
  
  <p>But a simple query like this:</p>
  
  <pre><code>$version = mssql_query('SELECT *  FROM [T32Database].[dbo].[TUsers]');
  $row = mssql_fetch_array($version);
  
  echo $row[0];
  </code></pre>
  
  <p>Produces this output:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function mssql_query() in C:\Users\kians_000\dev\traka\index.php on line 42</p>
  </blockquote>
  
  <p>phpinfo show me this:</p>
  
  <blockquote>
    <p>sqlsrv</p>
    
    <p>sqlsrv support    enabled</p>
    
    <p>Directive Local Value Master Value <br>
    sqlsrv.ClientBufferMaxKBSize  10240   10240 sqlsrv.LogSeverity    0   0 <br>
    sqlsrv.LogSubsystems  0   0 sqlsrv.WarningsReturnAsErrors On  On</p>
  </blockquote>
  
  <p>Edit 3:
  I tried out all drivers. This is the only one that works.
  Maybe something with my source is wrong.</p>
  
  <pre><code>&lt;?php
  
  //-----------------------------------------------
  // Connect to SQL Server DB
  //-----------------------------------------------
  
  $serverName = "KIAN-PC";
  $connectionInfo = array( "Database"=&gt;"T32Database");
  $conn = sqlsrv_connect( $serverName, $connectionInfo);
  
  if( $conn )
  {
      echo "Connection established.\n";
  }
  else
  {
      echo "Connection could not be established.\n";
      die( print_r( sqlsrv_errors(), true));
  }
  
  //-----------------------------------------------
  // Perform operations with connection.
  //-----------------------------------------------
  
  $version = mssql_query('SELECT *  FROM [T32Database].[dbo].[TUsers]');
  $row = mssql_fetch_array($version);
  
  echo $row[0];
  
  /* Close the connection. */
  sqlsrv_close( $conn);
  
  ?&gt;
  </code></pre>
  
  <p>My output is:</p>
  
  <blockquote>
    <p>Connection established.  ( ! ) Fatal error: Call to undefined function
    mssql_query() in C:\Users\kians_000\dev\traka\index.php on line 42</p>
  </blockquote>