|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-04-19 22:01 UTC] oooacooo at yahoo dot com
Description:
------------
When using mssql_execute() with PHP version 4.3.2 mssql_num_rows() will return 0, when no records are returned from a stored procedure.
When using version 4.3.4 and above mssql_num_rows() will return "supplied argument is not a valid MS SQL-result
resource"
I tested this by running the code successfully with the php_mssql.dll which ships with 4.3.2 and then swapped php_mssql.dll with the one that ships with 4.3.4 and restarted Apache.
Reproduce code:
---------------
$validEpisode = mssql_query("spValidateEpisodeDate " . $AccountID . ",'" . $inputVisitDate . "'",$db);
if(mssql_num_rows($validEpisode) > 0)
{
$row = mssql_fetch_object($validEpisode);
if($row->Episode_ID == "")
$errorMsg = "There is no episode for this account that covers the visit date entered.<br>" . $errorMsg;
else
$EpisodeID = $row->Episode_ID;
}
Expected result:
----------------
If no records are found I would expect "if(mssql_num_rows($validEpisode) > 0)" to return true.
Actual result:
--------------
"if(mssql_num_rows($validEpisode) > 0)" throws an error "supplied argument is not a valid MS SQL-result
resource"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 17:00:01 2025 UTC |
When mssql_query() returns true it means that the SQL statement(s) was executed without any errors and they did not return any data (result sets). You can't pass a true value to mssql_num_rows() it requires a resource handle. You can check if the returned value is a resource valye with this code: $rs = mssql_query(....); if (is_resource($rs)) { // continue }