Home  >  Article  >  Backend Development  >  Example: Call Microsoft SQL Server's stored procedure using PHP3_PHP Tutorial

Example: Call Microsoft SQL Server's stored procedure using PHP3_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 11:00:14847browse

Stored procedure (procedure.sql):
create procedure hello
@yourname varchar(50) = "无名士"
as
select @yourname + "Hello!"
go
PHP3 program (procedure.php3):
  $server = mssql_connect("localhost","sa","") or die("Unable to connect to the database server!");
$db = mssql_select_db("test",$server) or die("Unable to connect to test database!");
echo "

" ;
echo "";
$query = "exec hello @yourname="Friend"";
$rst = mssql_query($query,$db) or die("Unable to execute SQL :$query");
$fields_num = mssql_num_fields($rst);
$i=0;
while($i<$fields_num){
$fields[$i] = mssql_field_name( $rst,$i);
      echo "";
      $i++;
 }
 echo "< /tr>";
while ($record=mssql_fetch_array($rst)) {
echo "";
while ($i<$fields_num) {
  $value = $record[$fields][$i]];
if($value=="")
else
     Echo "
" . $fields[$i] . "
" . 🎜> mssql_free_result($rst);
echo "
";

mssql_close($server) or die("Unable to disconnect from the database server! ");
 ?>





http://www.bkjia.com/PHPjc/631832.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/631832.htmlTechArticleStored procedure (procedure.sql): create procedure hello @yourname varchar(50) = 无名士 as select @yourname + , hello! go PHP3 program (procedure.php3): ? $server = mssql_connect...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn