Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP to query SQL Server 2008 R2
    primarykey
    data
    text
    <p>We have a database running on Windows Server 2008 R2, SQL Server 2008 R2. I need to query the database via PHP (I'm also open to other options) and display the data in a web page.</p> <p>I have tested connectivity with my username, password and server name using a UDL test file. My connection is successful.</p> <p>My web server has PHP 5.4 installed and working.</p> <p>I have built a PHP script that is supposed to connect and query the database but I get a server error.</p> <pre><code>&lt;?php $myServer = "ipaddress"; $myUser = "username"; $myPass = "password"; $myDB = "dbname"; //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 fullName, email_address, pos_desc"; $query .= " FROM dbo.EMPLOYEE_VIEW "; $query .= "WHERE grp_cde='STAFF'"; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "&lt;h1&gt;" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned &lt;/h1&gt;"; //display the results while($row = mssql_fetch_array($result)) { echo "&lt;li&gt;" . $row["id"] . $row["name"] . $row["year"] . "&lt;/li&gt;"; } //close the connection mssql_close($dbhandle); ?&gt; </code></pre> <p>Keep in mind the Database server and the Web Server are both running Windows Server 2008 R2 and exist in the same domain.</p> <p>The only error I receive is: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.</p> <p>Is there anything I can do to troubleshoot why this is not working?</p> <p>I appreciate any and all help on this question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload