mssql_bind problems
| From: | Chris Wright | Date: | Wed, 09 Jul 2003 18:12:22 +0000 |
| Subject: | mssql_bind problems | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-29183@lists.php.net to get a copy of this message | ||
I am running PHP 4.3.2 and MS-SQL 2000. I am trying to run some sample
code to make sure all works well.
The code below works fine. It simply inserts a record into a table. This
is done in the stored procedure code on the SQL server.
Code that works:
$myServer = "192.168.200.28";
$myUser = "sa";
$myPass = "xxxxxx";
$myDB = "Northwind";
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
$query = mssql_init("sp_addnewshipper", $s);
$result = mssql_execute($query);
However, when I try to pass a variable via the following code, I get an
error from my proxy server saying "Zero sized reply". The problem seems to
be with the mssql_bind line.
Code that doesn't work:
$myServer = "192.168.200.28";
$myUser = "sa";
$myPass = "xxxxxx";
$myDB = "Northwind";
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
$query = mssql_init("sp_getprod", $s);
$supid = 2;
mssql_bind($query, "@supplierid", &$supid, SQLINT2,true);
$result = mssql_execute($query);
$numProds = mssql_num_rows($result);
echo "<h1>" . $numProds . " Product";
while($row = mssql_fetch_array($result))
{
echo "<li>".$row[0]."<li>";
}
?>