Re: MSSQL Stored Proc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 28, 2012 at 1:03 PM, Phillip Baker <phillip@xxxxxxxxxxxx> 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux