I have a MySQL database on my local machine and am trying to query it with PHP.
I've written out the following HTML/PHP code. When I open this HTML file in Chrome, this is what is displayed. Why does the browser treat this code as text?
ID Project Code'; while ($row = mysqli_fetch_array($response)){ echo '' . $row[Id] . '' . $row[Project_Code] . ''; echo ''; } echo ''; } else { echo "couldn't connect do it"; echo mysqli_error($dbc); } mysqli_close($dbc); ?>
code:
<HTML>
<body>
<?php
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'root');
DEFINE ('DB_HOST', 'my_local_ip');
DEFINE ('DB_NAME', 'my_db');
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die("couldn't connect");
$query = "SELECT Id, Project_Code FROM database.projects";
$response = @mysqli_query($dbc, $query);
if ($response){
echo '<table>
<td>ID</TD>
<td>Project Code</TD></table>';
while ($row = mysqli_fetch_array($response)){
echo '<tr><td>' .
$row[Id] . '</td></td>' .
$row[Project_Code] . '</td></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo "couldn't connect do it";
echo mysqli_error($dbc);
}
mysqli_close($dbc);
?>
</BODY>
</HTML>

.phpfile?HTML filewith PHP in it or aPHP filewith HTML in it? Big difference..