今天玩着没事,用php连接mssql server 2005的存储过程,出现小的错误
代码如下,
$host="localhost";
$user='sa';
$password='01211107';
$dbname='book';
$link=mssql_connect($host,$user,$password) or die('link failure');
if($link){
mssql_select_db('book');
}
$stmt=mssql_init('cheng',$link);
mssql_bind($stmt,'@ager', 25 ,SQLINT1,false,false,3);
$sp=mssql_execute($stmt);
while($row=mssql_fetch_assoc($sp)){
print_r($row);
}
存储过程为:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[cheng]
@ager smallint
as
begin
select count(*) as cou from student where age=@ager
end
在xdebug调试下,提示
Fatal error: Only variables can be passed by reference in D:\php5\test.php on line 16
只有变量可以通过引用传递的意思
mssql_bind(),第三个参数必须是变量