/    Sign up×
Community /Pin to ProfileBookmark

Need help on PHP calling StoredProc

Hi All,

I have this function:

[CODE] function getClientbyRess($IDClient){
$conn = new Connection();
$result = $conn->select(“rsGetClientIDbyRessInitials “.$IDClient);
if($result[0][‘IDClient’] > 0){
$initials = $this->getOriginalId($result[0][‘initials’]);
}
return $initials;
}//end function[/CODE]

values are most likely all in the wrong place but I did my best.
i’m sending IDclient to this function and initials is what is to be returned from the stored proc.

have I put the right variables in the right places?

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 08.2006 — are you getting the return value from a database?
Copy linkTweet thisAlerts:
@NaciremaauthorDec 08.2006 — no I get an error

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'rsGetClientIDbyRessInitials' expects parameter '@Initials', which was not supplied.

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'rsGetClientIDbyRessInitials' expects parameter '@Initials', which was not supplied.
Copy linkTweet thisAlerts:
@ShrineDesignsDec 08.2006 — ???

odbc is a database, so you need to use a proper SQL statementSELECT initials FROM rsGetClientIDbyRessInitials WHERE IDClient = '$IDClient'(i am guessing those are the correct names)
Copy linkTweet thisAlerts:
@NaciremaauthorDec 08.2006 — ???

odbc is a database, so you need to use a proper SQL statementSELECT initials FROM rsGetClientIDbyRessInitials WHERE IDClient = '$IDClient'(i am guessing those are the correct names)[/QUOTE]


select initials from rsGetClientIDbyRessInitials?
Copy linkTweet thisAlerts:
@NaciremaauthorDec 08.2006 — But that assumes that rsGetClientIDbyRessInitials is a table and not a storedProc doesn't it?

rsGetClientIDbyRessInitials is a storedProcedure
Copy linkTweet thisAlerts:
@NaciremaauthorDec 08.2006 — any1 can help?
Copy linkTweet thisAlerts:
@NaciremaauthorDec 11.2006 — someone plz help me out

I can't find a solution
Copy linkTweet thisAlerts:
@chazzyDec 11.2006 — Nacirema,

in general, stored procedures are called something like this:

<i>
</i>rsGetClientIDbyRessInitials('3')


I would recommend, if you could, to use the MS SQL Server connector in PHP, not the ODBC one to use it properly. Your statemenet should then look like:

[code=php]$result = $conn->select("rsGetClientIDbyRessInitials('".$IDClient."')");[/code]
Copy linkTweet thisAlerts:
@russellDec 11.2006 — here is the correct syntax for executing sql server stored procedures via PHP. everything in UPPER CASE needs to be changed to your actual values
[code=php]
$db = mssql_connect('SERVERNAME', 'LOGINNAME', 'PASSWORD');
$sp = mssql_init('YOUR_STORED_PROCEDURE', $db);
$param1 = $SOME_VALUE;

if ($db && mssql_select_db('DATABASE_NAME')) {
mssql_bind($sp, "PARAM_NAME_IN_STOREDPROC)", $param1, SQLINT4);
$rs = mssql_execute($sp);
mssql_close($db);
echo mssql_result($rs, 0, 'FIELD_NAME');
mssql_free_result($rs);
}
else {
echo "uh-oh. problem connecting to sql server";
}
[/code]
Copy linkTweet thisAlerts:
@NaciremaauthorDec 14.2006 — thanks guys

but I need to put it in a function and use this format:

function getOriginalId($quotId){
$conn = new Connection();
$result = $conn->select("rsGetQuotationByModifiedID ".$quotId);
if($result[0]['IDQuotation'] > 0){
$quotId = $this->getOriginalId($result[0]['IDQuotation']);
}
return $quotId;
}//end function



How do I do that?
×

Success!

Help @Nacirema spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...