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.

5
  • 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. Commented Apr 21, 2014 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) Commented Apr 21, 2014 at 18:43
  • turn on error_reporting and display_errors. white page = they're turned off and something blew up. Commented Apr 21, 2014 at 18:44
  • Have PHP print the error for you: if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } Commented Apr 21, 2014 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(); } Commented Apr 21, 2014 at 18:46

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.