3

I am trying to display the data from my table on my page and I have done it many times before. This time it is not working, I usually copy the code from my other projects and change the appropriate values but this time it's not working. Please note I am not quite sure what I am doing. I don't usually write code. This is using iis with php and the database server is mysql. The problem is I get a white page with no errors or other signs.

Here is the code.

<?php
require('connection.php');

$sql = "SELECT * FROM td";

$result = mysqli_query($con,$sql)or die(mysqli_error());

echo "<table>";
echo "<tr><th>Date</th><th>Comment</th><th>Amount</th></tr>";

while($row = mysqli_fetch_array($result)) {
    $date = $row['date'];
    $comment = $row['comment'];
    $amount = $row['amount'];
    echo "<tr><td style='width: 200px;'>".$date."</td><td style='width: 600px;'>".$comment."</td><td>".$amount."</td></tr>";
} 

echo "</table>"
mysqli_close($con);
?>

Oh and there is data in the table. Also the connection to the db is fine I use the same connection file to insert data to the table.

Wow that fixed it. I knew it was some stupidity on my part I just did notice it.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
chromatel
  • 59
  • 2
  • 2
  • 6
  • Right click on the white page and view source. Sometimes there will be an error to see, but because no style loads, you get white on white. I had this EXACT thing happen to me just last week. – durbnpoisn Apr 21 '14 at 18:42
  • I don't see any errors in the source (it could be my server is set to not show errors but that's another problem I will fix later) – chromatel Apr 21 '14 at 18:43
  • turn on error_reporting and display_errors. white page = they're turned off and something blew up. – Marc B Apr 21 '14 at 18:44
  • Have PHP print the error for you: if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } – durbnpoisn Apr 21 '14 at 18:44
  • I am really slow with this coding stuff where do I paste that line of code if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } – chromatel Apr 21 '14 at 18:46

1 Answers1

4
echo "</table>";

you forget the ";" :D. And if that did not help, maybe the result is empty and there's nothing to show? That may be why you got a white screen.

Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159
Pain67
  • 326
  • 1
  • 9