I have searched around here and other sources for a solution to this issue but so far no luck finding the answer that solves the issue.
When trying to query and fetch the result from a MS SQL 2008 database I get an Array to string conversion error in the sqlsrv_query line.
This is the php code for accessing and querying.
<?php
/* Specify the server and connection string attributes. */
$serverName = "DATABASE";
$connInfo = array( "Database"=>"Suggestion");
$conn = sqlsrv_connect( $serverName, $connInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
$query = "SELECT * FROM dbo.Suggestions";
$result = sqlsrv_query($conn, $query) OR die(sqlsrv_errors());
$val=sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC);
echo $val;
?>
EDIT: As requested the actual error code below:
Notice: Array to string conversion in C:\wamp\www\DBTest\index.php on line 24
When taken into context of the entire file index.php line 24 is:
$result = sqlsrv_query($conn, $query) OR die(sqlsrv_errors());
Thanks in advance for any help!