I have recently started to upgrade my intranet server to PHP but i am having trouble getting the code to work.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" x-undefined>
</head>
<body>
<!-- php data test -->
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="Sat, 31 Oct 2014 00:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
</body>
</html>
<?php
// Connect to MSSQL and select the database
mssql_connect('intranet', 'sa', 'bobby123');
mssql_select_db('phptable');
// Send a select query to MSSQL
$query = mssql_query('SELECT * FROM [php].[dbo].[persons]');
// Construct table
echo '<h3>Table structure for \'persons\'</h3>';
echo '<table border="1">';
// Table header
echo '<thead>';
echo '<tr>';
echo '<td>UserID</td>';
echo '<td>Username</td>';
echo '<td>Password</td>';
echo '</tr>';
echo '</thead>';
// Dump all fields
echo '<tbody>';
for ($i = 0; $i < mssql_num_fields($query); ++$i) {
// Fetch the field information
$field = mssql_fetch_field($query, $i);
// Print the row
echo '<tr>';
echo '<td>' . $field->userid . '</td>';
echo '<td>' . $field->username . '</td>';
echo '<td>' . $field->password . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
// Free the query result
mssql_free_result($query);
?>
I am using PHP 5.4 and have also tried to use 5.5 Is this something in my code, or do i need to install a plugin or something onto my server? (Windows Server 2012 R2)
<?php echo '<p>Hello World</p>'; ?>
and if it works then go to more complicated tests.error_reporting
. After setting that, RTFM (there are complete examples!) and use Stack Overflow.