日期:2013-09-01  浏览次数:20493 次

<?php
$hostname = "tszzp";
$dbuser = "sa";
$dbpasswd = "";

$id = mssql_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
//printf("%d<BR>\n", $id);
$db = mssql_select_db("stock",$id) or die("无法连接stock数据库!");
$stockcode='600600';
$id = 0;
$msg = 0;
//printf("%d<BR>\n", $db);
//$query = "exec sp_test @code='600028',@id=0,@msg='000000'";
$query = "declare @result int, @id int, @msg varchar(20)\n";
$query.="exec @result=sp_test\n";
$query.="\"$stockcode\",\n";
$query.="@id output,\n";
$query.="@msg output;\n";
$query.="select @result result, @id id, @msg msg";
/*$query = "declare @result int, @id int, @msg varchar(20)\n";
$query.="exec @result=sp_test\n";
$query.="\"$stockcode\",\n";
$query.="@id output,\n";
$query.="@msg output;\n";
$query.="select @result result, @id id, @msg msg";
*///$query = "update test set stockname='2test' where stockcode='600028'";
//$query = "insert into test(stockcode,stockname,id) values ('600028','test',13)";
//$query = "select * from test where stockcode='600028'";
//$query = "select 0 where 1=0 ";
$rresult = mssql_query($query) or die("无法执行SQL:$query");
$arr = mssql_fetch_array($rresult);
print $result;
print "<br>\n";
printf("%d, %d, %s<br>\n", $arr[result], $arr[id], $arr[msg]);
printf("%d, %s<br>\n", $id, $msg);
//$stock = mssql_fetch_array($result);
//$name = $stock[id];
//print $name;
//print "abc";

?>