Re: Help with MSSQL and Stored Procs

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

 



On Wed, Aug 29, 2012 at 3:14 PM, Phillip Baker <phillip@xxxxxxxxxxxx> wrote:
> I am trying to access a MSSQL DB on another system.
> I am having trouble executed a stored proc and debugging the problem./
>
> I have included the code below.
> I can connect to the DB just fine.
> I also can run regular queries on the DB and get a result set.
> We can also run the stored proc manually with the data in $xmlstring and
> that runs fine.
>
> However the mssql_execute is failing.
> I am getting the Execute failed die message however I am not getting
> anything for mssql_get_last_message
>
> So I have no idea what is happening.
> And ideas for solutions or at least to get more debugging information would
> be awesome.
>
> I know SQLSRV is a more recent option however we do not have it installed
> on the server and will likely not get that to happen so I need to get this
> debugged.
>
> $link = mssql_connect($myServer, $myUser, $myPass)
>     or die("Couldn't connect to SQL Server on $myServer");
> mssql_select_db($myDB, $link)
>     or die("Couldn't select database $myDB");
> if(!$link){
>     die('Error connecting to MSSQL database at '.$myServer);
> } else {
>     $version = mssql_query('SELECT @@VERSION');
>     $row = mssql_fetch_array($version);
>     mssql_free_result($version);
>
>     echo $row[0].'<br /><br />';
> }
> $storedproc = "Sp_DialerValidLead";
> $param = "ValidLeadText";
>
> $stmt = mssql_init('Sp_DialerValidLead', $link)
> or die("Unable to initialize");
>
> mssql_bind($stmt, "@".$param, $xmlstring, SQLVARCHAR)
>     or die("Unable to bind
> @ValidLeadText:$storedproc<br>".mssql_get_last_message());
>
> $result = mssql_execute($stmt)
>     or die ("Execute failed. Message:".mssql_get_last_message());
>
> var_dump($result);
>
>
> Blessed Be
>
> Phillip

I had to go to an old server that we are phasing out to find something
that had php_mssql installed on it, but once I got everything set up
it everything worked fine for me. I tested it with everything correct
as well as with a variety of forced errors (procedure doesn't exist,
user does not have permission to execute, parameter name different
than passed by PHP, etc.) and they all displayed error messages using
the code you posted above.

The server is running PHP 5.2.12, and this one can only connect to our
SQL Server 2000 instance, so I can't test it against SQL 2008.

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