php hangs on connect to a database request

General discussion on PHP
Post Reply
patr3492
Posts: 1
Joined: Wed Nov 11, 2015 2:36 pm

php hangs on connect to a database request

Post by patr3492 » Wed Nov 11, 2015 3:16 pm

I'm using iis7, and have installed php 3.2.0.0
Everything works fine until I try to connect to the database.
Here is what I have done so far...

<html>
<head>
<title>Array Functions</title>
</head>
<body>
<?php $array1 = array(4,8,15,16,23,42); ?>

Count: <?php echo count($array1); ?><br />
Max value: <?php echo max($array1); ?><br />
Min value: <?php echo min($array1); ?><br />
<br />
Sort: <?php sort($array1); print_r($array1); ?><br />
Reverse Sort: <?php rsort($array1); print_r($array1); ?><br />
<br />
Implode: <?php echo $string1 = implode(" * ", $array1); ?><br />
Explode: <?php print_r(explode(" * ", $string1)); ?><br />
<br />


<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'SQL\SQLEXPRESS';

/* Connect to MSSQL
$link = mssql_connect($server, 'sa', 'phpfi'); */
$options = array("UID" =>"sa", "PWD" => "password", "Database" => "test");
$link = sqlsrv_connect($server, $options);

if (!$link) {
die('Something went wrong while connecting to MSSQL');
}

?>


In array: <?php echo in_array(15, $array1); // returns T/F ?><br />

</body>
</html>


This is what I get when I browse to it with firefox:

Count: 6
Max value: 42
Min value: 4

Sort: Array ( [0] => 4 [1] => 8 [2] => 15 [3] => 16 [4] => 23 [5] => 42 )
Reverse Sort: Array ( [0] => 42 [1] => 23 [2] => 16 [3] => 15 [4] => 8 [5] => 4 )

Implode: 42 * 23 * 16 * 15 * 8 * 4
Explode: Array ( [0] => 42 [1] => 23 [2] => 16 [3] => 15 [4] => 8 [5] => 4 )

Note that this got just to the place to where it is making a call to connect to the database
and it stops, Doesn't even tell me that there is no connection.

Now I have a question... Could this problem be related to permissions?
I was thinking that perhaps php is running okay until it tries to access the
database. I created a test database with microsoft SQL server 2014 Management
Studio, but why does php hang at the request to connect?

Post Reply