I have established a connection with my SQL Database through Windows Authentication in my php file. However I'm not sure how the syntax will look if I wanted to display a simple SQL query such as (Select * from Media) on the php page that shows an entire table. I tried a few methods but it displayed a fatal error.
Here is my code for the php:
<?php
$serverName = "172.20.90.170,5050"; //serverName\instanceName
// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"TestDB");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
$version = mssql_query('SELECT * FROM MEDIA');
$row = mssql_fetch_array($version);
echo $row[0];
?>
Fatal Error:
Fatal error: Call to undefined function mssql_query()
This establishes a succesful connection but what would I need to change in my code for this query to run error free and display the required output?
sqlsrv_functions?sqlsrv_connect, why then do you try to usemssql_query? Don't you want to usesqlsrv_query?