hello
its a fairly difficult question, please help if you can!!!!
problem - trying to make a php script that executes a stored procedure (sp) on a MSSQL (not mysql) database.
the problem is that i can only refer to each column in the recordset by its number not its name.
heres the php function below. The stored procedure is called sp_authorise.
PHP Code:
function f_authorise_user($database, $link){ //this function returns the user type value of the current user logged in.
$user_type = "0";
If($_SESSION["current_user"] !== ""){ //current user is logged in
$query = mssql_init("sp_authorise", $link);
// Bind the parameters
mssql_bind($query, "@username", $_SESSION['current_user'], SQLCHAR, false, false, 20);
$result = mssql_execute($query);
while($row = mssql_fetch_row($result)){
$user_type = $row[3];
}
}
return $user_type; //return user type. if 0, this means no user logged in or user inactive. other values refer to a logged in user of varying type.
}
heres the sp:
CREATE PROCEDURE sp_authorise @username CHAR(20)
AS
SELECT * from [user] WHERE use_username=@username
GO
I can only refer to the column "use_type" in the database table by its recordset number, 3.
This will be a problem in the larger queries where i will have 200 or more columns (hence the need for SPs)
if anyone can help, very appreciated
- dgr