Asked  7 Months ago    Answers:  5   Viewed   38 times

I'm trying to connect from php to Azure DB by

$connectionInfo = array("UID" => "xxx@xxx", "pwd" => "xxx", "Database" => "xxx");
$serverName = "tcp:xxx.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);

But it gives me

Fatal error: Call to undefined function sqlsrv_connect() in C:wampwww...index.php on line 19

 Answers

23

you have to use the SQL Server native driver for php at first place, then you can do something like:

$serverName = "tcp:sample.database.windows.net, 1433";

$connectionOptions = array("Database" => "sampleInit", 

                           "UID" => "sampleUsr@sample",

                           "PWD" => "samplePass",

                           "MultipleActiveResultSets" => false);

$conn = sqlsrv_connect($serverName, $connectionOptions);

if($conn === false)

{

     die(print_r(sqlsrv_errors(), true));

}

You can read more on PHP and SQL Azure at following blog post:
http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx

Wednesday, March 31, 2021
 
MGP
answered 7 Months ago
MGP
25

You dont have a function named assign(), but a method with this name. PHP is not Java and in PHP you have to make clear, if you want to call a function

assign()

or a method

$object->assign()

In your case the call to the function resides inside another method. $this always refers to the object, in which a method exists, itself.

$this->assign()
Wednesday, March 31, 2021
 
ericstumper
answered 7 Months ago
10

In CI framework, if you are running a prod application, we can set pconnect to true in config/database.php to use a persistent connection to database. Which can reduce latency on initial connection.

By the way, if you are running a test or dev application, we need to treat carefully with this setting, because it may cause several unexpected issues. You can refer to the answer of Advantages / Disadvantages of pconnect option in CodeIgniter to get more info.

Saturday, May 29, 2021
 
Marcelo
answered 5 Months ago
67

I get a org.jivesoftware.smack.SmackException$ConnectionException and that's it.

No, it's not. If you look at the javadoc for ConnectionException:

ConnectionException is thrown if Smack is unable to connect to all hosts of a given XMPP service. The failed hosts can be retrieved with getFailedAddresses(), which will have the exception causing the connection failure set and retrievable with HostAddress.getException().

So call ConnectionException.getFailedAddresses() to retrieve the list and check with HostAddress.getException() what caused Smack to be unable to connect to the host.

Wednesday, July 7, 2021
 
Evernoob
answered 4 Months ago
19

You can create an elastic pool in the same server as your databases, through portal using instructions here - https://azure.microsoft.com/en-us/documentation/articles/sql-database-elastic-pool-create-portal/

Once you have created a pool, you can add existing databases to the pool using instructions here - https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-pool#manage-an-elastic-pool-and-its-databases

Let us know if you have any further questions here.

-- srini

Saturday, September 11, 2021
 
ramdemon
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :