Alright. Right now, I'm working on a Register script. The POST data, and stuff like that works fine, it's only the Stored Procedure that's bothering me. Everytime I "attempt to register", it comes up with the error:

Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /usr/local/lsws/DEFAULT/html/configs/class.php on line 1038

We're running on:
PHP Version 5.3.6
Linux 2.6.18-238.9.1.el5.pony5-1 #3 SMP Fri Jun 3 16:37:31 PDT 2011 i686
LiteSpeed V5.5

With MySQLi, MySQL, And MsSQL(Plugins).

Here's the stored procedure:


USE [ACCOUNT_DBF]
GO
/****** Object:  StoredProcedure [dbo].[createaccount]    Script Date: 08/03/2011 23:42:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[createaccount] 
@account VARCHAR(15),
@password VARCHAR(32),
@email VARCHAR(max),
@ques int,
@answer VARCHAR(max),
@date VARCHAR(50),
@time VARCHAR(50),
@ip VARCHAR(MAX),
@string VARCHAR(MAX)

AS

SET NOCOUNT ON

DECLARE @DateActivated AS CHAR(8)

IF NOT EXISTS (SELECT account FROM ACCOUNT_TBL WHERE account = @account) BEGIN
INSERT INTO ACCOUNT_TBL (account, [password], id_no2, isuse, member, realname, support_key) 
VALUES (@account, @password, @password, 'T', 'A', 'F', @string)

SET @DateActivated = CONVERT(CHAR(8), GETDATE()-1, 112 ) --Is the date today - 1
--UPDATE ACCOUNT_TBL_DETAIL SET BlockTime = @DateYesterday WHERE account = @userid	
--INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse)
--	VALUES (@account, 'A000', '2', 'F', GETDATE(), '20990101', '20990101', '20050101', 'O')

INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse, email, security_question, security_answer, ip, [date], [time])
VALUES (@account, 'A000', '2', 'F', GETDATE(), @DateActivated, '20990101', '20050101', 'O', @email, @ques, @answer, @ip, @date, @time)

END

Here's the PHP calling the Procedure:

public function createAccount($username, $password, $email, $security_question, $security_answer, $ip, $date, $time, $key)
	{
			$string = md5("1n5t1nctk4y5f0rth3w1n".$key);
			$stmt = mssql_init('ACCOUNT_DBF.dbo.createaccount');
			mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 15);
			mssql_bind($stmt, '@password', $password, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@email', $email, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@ques', $security_question, SQLINT1, false, false, 36);
			mssql_bind($stmt, '@answer', $security_answer, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@date', $date, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@time', $time, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@ip', $ip, SQLVARCHAR, false, false, 36);
			mssql_bind($stmt, '@string', $string, SQLVARCHAR, false, false, 36);
			mssql_execute($stmt) or die ("[Function Error]: Cannot Register account.<BR>".mssql_get_last_message()."");
			mssql_free_statement($stmt) or die(mssql_get_last_message());
			/*$this->mailUser($username, $pass, $email, $date, $time, $key);*/
			echo "<script language='Javascript'>alert('[Success]: Your account has been created successfully!');</script>";
	}

Any suggestions?

    I've never used MsSQL, but since noone else have answered so far, I'll just give you the few questions I have.

    Are you really looking at the code being executed? And if you are, did you post all error messages?

    die("[Function Error]: Cannot Register account.<BR>".mssql_get_last_message());
    

    Should output

    Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /usr/local/lsws/DEFAULT/html/configs/class.php on line 1038
    

    But you posted this

    Apixen;10985553 wrote:
    Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /usr/local/lsws/DEFAULT/html/configs/class.php on line 1038
    

    Are you executing a query before executing this statement but without first calling mssql_free_result() ?

    Can you execute the procedure using mssql_query by issuing these commands in SQL instead, using DECLARE, EXEC...? Or do the same directly in MsSQL CLI?

      johanafm;10985577 wrote:

      I've never used MsSQL, but since noone else have answered so far, I'll just give you the few questions I have.

      Are you really looking at the code being executed? And if you are, did you post all error messages?

      die("[Function Error]: Cannot Register account.<BR>".mssql_get_last_message());
      

      Should output

      Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /usr/local/lsws/DEFAULT/html/configs/class.php on line 1038
      

      But you posted this

      Are you executing a query before executing this statement but without first calling mssql_free_result() ?

      Can you execute the procedure using mssql_query by issuing these commands in SQL instead, using DECLARE, EXEC...? Or do the same directly in MsSQL CLI?

      The error given is a "PHP" error. Hence why it says Warning:. MSSQL error are just plain out direct.

      I'll go ahead and mark this as resolved. I found an alternative to do this.

        Write a Reply...