I tried the same script on my Linux environment (I am not running on Windows), and it worked flawlessly. The point of the script (although irrelevant) is to print out the contents of a table.
The script is as follows:
table_contents.php
<?
$user="root";
$password="";
$database="newtest";
$con = mysqli_connect(localhost,$user,$password,$database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query="SELECT * FROM contacts";
$result = mysqli_query($con,$query);
$num = mysqli_num_rows($result); // COUNT for FOR LOOP
echo '<table border=\'1\'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>'; //This is where it starts printing out everything.
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['first'] . "</td>";
echo "<td>" . $row['last'] . "</td>";
echo "</tr>";
}
mysqli_close($con);
?>
And the table_contents.php displays the following line on my browser:
Firstname Lastname '; while($row = mysqli_fetch_array($result)) { echo ""; echo "" . $row['first'] . ""; echo "" . $row['last'] . ""; echo ""; } mysqli_close($con); ?>
Indicating that the commented line in the script above is the point after which is throws everything out to be displayed.
Why is this being caused and how can I fix this?