[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] MSSQL Stored Proc
From:       Andrew Ballard <aballard () gmail ! com>
Date:       2012-08-28 17:17:00
Message-ID: CAC1b6RuCt2MsoXoEobi57rTyh_CdoR6XaSzRth0K0PwCrhn8Ug () mail ! gmail ! com
[Download RAW message or body]

On Tue, Aug 28, 2012 at 1:03 PM, Phillip Baker <phillip@freewolf.net> wrote:
> Greetings all,
>
> I am having some trouble with running a stored proc on an MSSQL DB.
> I am new to using MSSQL.
>
>
>
> $link = mssql_connect($server, $db, $password);
>
>
>
> if(!$link){
>
>                 die('Error connecting to MSSQL database at '.$server);
>
> } else {
>                 $storedproc = "SP_DialerValidLead";
>
>                 $param = "ValidLeadText";
>
>
>
>                 $stmt = mssql_init($storedproc, $link)
>
>                                 or die("Unable to initialize");
>
>
>
>                 mssql_bind($stmt, "@".$param, $xmlstring, SQLTEXT, FALSE)
>
>                                 or die("Unable to bind
> $param:$storedproc<br>".mssql_get_last_message());
>
>
>
>                 $result = mssql_execute($stmt);
>
>
>
>                 var_dump($result);
>                 mssql_close($link);
>
> }
>
>
> Apparently there is no data getting passed to the stored proc.
>
> The $xmlstring is a valid xml string and the variable is properly set in
> the code above.
>
> Is there something obvious in how I am trying to call the stored proc with
> the PHP code?
> Any ideas or further questions?
>

I just skimmed your code, but the only thing that sticks out is your
call to mssql_connect(). The second parameter should be the username,
not the database. To select a specific database, you use
mssql_select_db() after mssql_connect() returns a valid resource.

However, if you have the choice, you really should switch to the SQL
Server driver for PHP developed by Microsoft. The mssql library has
been phased out.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic