sushant sagar on Tue, 21 Oct 2014 07:06:46
I'm trying to connect to sql server on azure through php.
The code I'm using is:
$myServer = "my_servaer_name.database.windows.net";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "name_db";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT id, name, year ";
$query .= "FROM cars ";
$query .= "WHERE name='BMW'";
//execute the SQL query and return records
$result = mssql_query($query);
//close the connection
but when this php file runs the server gives 500 internal error
I tried using mysql_connect, mysql_select_db instead of mssql_connect and mssql_select_db
I didn't get 500 server internal error but on debugging i found that the code was not able to connect to the server.
Mekh Subba on Tue, 21 Oct 2014 08:42:26
Please have a check on the below links which talks about how to connect to Azure SQL database using PHP.
sushant sagar on Wed, 22 Oct 2014 07:36:02
Thank you @Mekh
I got it done.$connectionInfo = array("UID" => "myuser@server", "pwd" => "mypass", "Database" => "mydb_dba",
"LoginTimeout" => 30, "Encrypt" => 1);
$serverName = "tcp:server.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);
Mekh Subba on Wed, 22 Oct 2014 09:13:47
I am glad that you have the issue sorted.
Please let us know if you have any other issues.
sushant sagar on Wed, 22 Oct 2014 11:05:15
the following code is not working for me$to = $email;
$subject = "Microsoft Developer Group";
$message = "Thank you for registering with us..";
$from = "email@example.com";
$headers = "From:" . $from;
please help me in this. i am not able to send mail through php
while writing parameters in insert query do we have to put the varchar parameters in quotes and numeric ones without them like we do in oracle database or its ok anyway.