note 71121 added to function.mssql-get-last-message
| From: | php at cybertinus dot nl | Date: | Mon, 13 Nov 2006 11:50:38 +0000 |
| Subject: | note 71121 added to function.mssql-get-last-message | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119655@lists.php.net to get a copy of this message | ||
Here I am again :). My last function stinks :p (well, actually, MSSQL doesn't always does the
same thing with different errors :/. That last function can't cope with that. The following
function can cope with that. The only weird thing I had with it was that when I entered a table,
which don't exists, in my SELECT query, the first mssql_get_last_message() doesn't always
gets the correct message. It sometimes gets the message from the last action. I have no explination
for it. Anyway: this is the beter version of my last function. The usage is explained in my last
post:
<?php
function query($sQuery, $hDb_conn, $sError, $bDebug)
{
if(!$rQuery = @mssql_query($sQuery, $hDb_conn))
{
$sMssql_get_last_message = mssql_get_last_message();
$sQuery_added = "BEGIN TRY\n";
$sQuery_added .= "\t".$sQuery."\n";
$sQuery_added .= "END TRY\n";
$sQuery_added .= "BEGIN CATCH\n";
$sQuery_added .= "\tSELECT 'Error: ' + ERROR_MESSAGE()\n";
$sQuery_added .= "END CATCH";
$rRun2= @mssql_query($sQuery_added, $hDb_conn);
$aReturn = @mssql_fetch_assoc($rRun2);
if(empty($aReturn))
{
echo $sError.'. MSSQL returned: '.$sMssql_get_last_message.'.<br>Executed
query: '.nl2br($sQuery);
}
elseif(isset($aReturn['computed']))
{
echo $sError.'. MSSQL returned:
'.$aReturn['computed'].'.<br>Executed query: '.nl2br($sQuery);
}
return FALSE;
}
else
{
return $rQuery;
}
}
?>
Disclaimer: This is not the original function that I use in my project. The original function has
Dutch text and uses some other functions that I have. I have removed my own functions and translated
everything to English. That is everything I did. I only used a second function for the error
messages. So I think everything should work, but I don't know for sure.
----
Server IP: 194.109.193.119
Probable Submitter: 84.24.126.59
----
Manual Page -- http://www.php.net/manual/en/function.mssql-get-last-message.php
Edit -- https://master.php.net/note/edit/71121
Del: integrated -- https://master.php.net/note/delete/71121/integrated
Del: useless -- https://master.php.net/note/delete/71121/useless
Del: bad code -- https://master.php.net/note/delete/71121/bad+code
Del: spam -- https://master.php.net/note/delete/71121/spam
Del: non-english -- https://master.php.net/note/delete/71121/non-english
Del: in docs -- https://master.php.net/note/delete/71121/in+docs
Del: other reasons-- https://master.php.net/note/delete/71121
Reject -- https://master.php.net/note/reject/71121
Search -- https://master.php.net/manage/user-notes.php