note 21728 added to function.mssql-get-last-message

From: Date: Fri, 24 May 2002 14:58:15 +0000
Subject: note 21728 added to function.mssql-get-last-message
Groups: php.notes 
Request: Send a blank email to php-notes+get-30983@lists.php.net to get a copy of this message
If you work with stored procedures and want to have a neat error-handling, try this: procedure: CREATE PROCEDURE TEST_ERROR AS RAISERROR('myMessage:test', 2, 1) WITH SETERROR 2 is error-severity, which should be below 11 to prevent php to output error directly. you get this message with mssql_get_last_message() after executing the stored procedure. To prevent your code from reacting on all messages you can define a string (e.g. 'myMessage:') and parse for it: <?php $db = mssql_connect(DBHost, DBLogin, DBPassword); mssql_select_db(DBName, $db); $query = "exec TEST_ERROR"; $rs = mssql_query($query, $db); $lastMsg = mssql_get_last_message(); if strstr($lastMsg, 'myMessage:') echo $lastMsg; ?> -- http://www.php.net/manual/en/function.mssql-get-last-message.php http://master.php.net/manage/user-notes.php?action=edit+21728 http://master.php.net/manage/user-notes.php?action=delete+21728 http://master.php.net/manage/user-notes.php?action=reject+21728

« previous php.notes (#30983) next »