0
votes

After running my PHP Program I am getting the error as follows:

Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )

I have installed all extension and enabled in PHP. but I am still getting this error.

<?php


$serverName ="tcp:myserver.database.windows.net,1433";
$usr="username";
$pwd="password";
$db="SensorDataBase";

$connectionInfo = array("UID" => $usr, "PWD" => $pwd, "Database" => $db);

$conn = sqlsrv_connect($serverName, $connectionInfo);
if( $conn )
{
    echo "Connected";
}
else
{
    echo "Error As follows: ";
    die( print_r( sqlsrv_errors(), true));
}

$sql = "CREATE TABLE fyi_links ("
    . " id INT NOT NULL VARCHAR (6)" 
    . ", url VARCHAR(80) NOT NULL"
    . ", notes VARCHAR(1024)"
    . ", counts INT"
    . ", time DATETIME"
    . ")";
$res = sqlsrv_query($conn, $sql);
//$res = sqlsrv_query($sql,$conn);
if (!$res) {
    print('Table creation failed with error:\n');
    print("   ".sqlsrv_get_last_message()."\n");
}
else {
    print("Table fyi_links created.\n");
}  

mssql_close( $conn);

?>
1
Silly question but did you install Microsoft ODBC Driver 11 If not its here on the microsoft site - RiggsFolly
Thankyou. Though I given access to '116.73.45.2' in MS Azure I'm getting this error: Client with IP address '116.73.45.2' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. - user6277159
That sounds like a candidate for a new question, with some different tags on it - RiggsFolly
@TaleWords Please STOP editing [sqlsrv] to [sql-server]. Read the tag descriptions, they are fundamentally different, they are not synonyms. - Adriaan

1 Answers

-1
votes

for the solution of this problem I did the following, I went in this link: https://microsoft.com/en-gb/download/details.aspx?id=3643, select your system, if is x86 or x64, install and test. This solved my problem.