Hi All,
I know that this is a little off in regards to php and MySQL but I have an SQL programmer helping me with setting up some database integration with our MSSQL 2005 server and he wrote some stored procedures that I am not able to get a successfull query from.
I went to these three sites looking for examples.
First site.
Second site.
Third site.
And they give examples of...
mssql_bind($proc, "@minPrice", $minPrice, SQLFLT8);
And I tried it here.
$msconnect=mssql_connect("x","x","x") or die("Could not connect to the database.");
$msdb=mssql_select_db("MarketTest",$msconnect) or die("Could not select the database.");
$query = mssql_init("sp_GetUserField", $msconnect);
mssql_bind($query, "@FieldName", $FieldName, SQLVARCHAR, FALSE, FALSE, 30);
mssql_bind($query, "@LastName", &$LastName, SQLVARCHAR, FALSE, FALSE, 80);
mssql_bind($query, "@FirstName", $FirstName, SQLVARCHAR, FALSE, FALSE, 80);
echo 'start the loop<br />';
$result = mssql_execute($query) or die("No results from that query.");
echo 'The result is '.$result.'<br />';
echo $Last_Name.'<br /><br />';
$number = mssql_num_rows($result);
echo 'The number of rows selected is: '.$number.'<br />';
while ($row=mssql_fetch_array($result)) {
echo 'The last name is '.$row['Name'].'<br />';
}
echo '<br /><br />end the loop';
$num = mssql_num_rows($result);
while ($row = mssql_fetch_array($result)) {
echo "<br /><br /><br /><li>". $row['FieldName'] . " " . $row['LastName'] . " " . $row['FirstName'] . " " . "</li>\n";
}
echo '<br /><br />Total number of records in the database is :'.$num;
mssql_close($msconnect);
And I get ...
start the loop
The result is Resource id #4
The number of rows selected is: 0
end the loop
Total number of records in the database is :0
But when I try it without using his stored procedure...
$msconnect=mssql_connect("x","x","x") or die("Could not connect to the database.");
$msdb=mssql_select_db("MarketTest",$msconnect) or die("Could not select the database.");
$query = mssql_query("SELECT * FROM AMGR_Client_Tbl WHERE Use_Client_Name='1'") or exit(mysql_error());
$total_rows = mssql_num_rows($query);
echo 'The total number of records is '.$total_rows.'<br /><br />';
$x=1;
while ($row = mssql_fetch_array($query) or die (mysql_error())) {
echo $x.') '.$row['First_Name'].' '.$row['Name'].'<br />';
$x++;
}
echo '<br /><br />end the loop';
mssql_close($msconnect);
I get...
The total number of records is 5
1) Melody Smith
2) Dan Jones
3) Ward Wilson
4) Steve Andrews
5) Jim Green
I read the php.net description of mssql_bind and I don't understand all the parameters in regards to his stored procdure.
Does anyone have any links to better examples or firsthand experience in this?
I know that he setup the queries in his stored procdures, if that helps.
Note: I did install PEAR, but I am not familar with it and I could not verify that it is fully operational and running to the correct setup.
Thanks in advance,
Don