I need help connecting PHP with SQL Server, or is this trying to get water and oil together? I leave a comment in https://docs.microsoft.com/en-us/sql/connect/php/how-to-retrieve-output-parameters-using-the-sqlsrv-driver
Playing with this code (URL) I get this error:
Variable parameter 2 not passed by reference (prefaced with an &). Output or bidirectional variable parameters (SQLSRV_PARAM_OUT and SQLSRV_PARAM_INOUT) passed to sqlsrv_prepare or sqlsrv_query should be passed by reference, not by value
If I use
$params = array(
array($lastName, SQLSRV_PARAM_IN), array(&$salesYTD, SQLSRV_PARAM_OUT) );
echo $salesYTD;
the value showed is a long text (all PHP code)
After thinking about the problem, my guess is you code is correct with &.
I think you didn't initialize the variable before use in the query. Initialize it like this:
$salesYTD = 0.0;
This sets the internal datatype in PHP to float.
or
You need to specify the PHP type in query: https://docs.microsoft.com/en-us/sql/connect/php/how-to-specify-php-data-types
NOT AT ALL, we have done it with great success using freeTDS.
take a look at http://www.freetds.org/userguide/php.htm It looks complicated but honestly it isn't really and it works well.
found this nice tutorial for Linux : http://www.informaticapressapochista.com/linux/connect-php-code-ms-sql-server-freetds/
We use it on MAC with brew
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.