Hi,
I am working on a project that will require my app to connect to a Microsoft SQL server 2008 database.
I cannot seem to find a decent walk through or code to help me make this connection. I have tried a few different methods including ajax and PHP … does any one have a working example I can see or a link to a basic walk through that might help me?
I appreciate any advice people can give
Code below…
Thanks
Thomas
I am trying to use $http to get within my controller:
$http({ method: 'GET', url: 'app/attendance/index.php' }).success(function (response) {
$scope.names = response;
});
my php looks like this:
<?php $serverName = "myServerName\sqlexpress"; //serverName\instanceName $connectionInfo = array( "Database"=>"Mobile_App_Test", "UID"=>"userName", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); //declare the SQL statement that will query the database $query = "SELECT * FROM Attendstu"; //create an array $emparray = array(); while($row =sqlsrv_fetch_assoc($result)) { $emparray[] = $row; } //write to json file $fp = fopen('app/attendance/testJson.json', 'w'); fwrite($fp, json_encode($emparray)); fclose($fp); //close the db connection mysqli_close($connection); ?>It seems that the controller never enters the php file. I have added a break point to the connection string but it doesnt make it that far.
Has anyone any idea?
Thanks again