1

I'm attempting to populate a table in HTML with data from a DB. It's not working properly (a blank white page is displayed), but I can't find the source of the error.

<?php    
$sql = "SELECT * FROM Orders";
$result = mysql_query($sql)or die(mysql_error());

echo "<table>";
while($row = mysql_fetch_array($result)){
  $order_id = $row['orderID'];
  $order_due = $row['order_due'];
  $order_subject = $row['order_subject'];
  $order_level = $row['order_level'];
  $order_pages = $row['order_pages'];
  $order_cost = $row['order_cost']); 
  echo "<tr><td>".$order_id."</td><td>".$order_due."</td><td>".$order_subject."</td><td>".$order_level."</td><td>".$order_pages."</td><td>".$order_cost."</td></tr>";   
}
 echo "</table>";
 ?>
4
  • 1
    try at the top of the script error_reporting(E_ALL); ini_set('display_errors', 1); - see what will be reported Commented Sep 19, 2013 at 16:58
  • Placed this in the PHP tag right at the top of the page, still just a blank white page after refreshing (In Firefox), tried it in IE and got a HTTP 500 Internal Server Error Commented Sep 19, 2013 at 17:02
  • Use: ini_set("error_reporting", E_ALL); ini_set("display_errors", 1); That should hopefully give you an error message. Commented Sep 19, 2013 at 17:05
  • Nope... same blank page :/ Commented Sep 19, 2013 at 17:07

2 Answers 2

1
$order_cost = $row['order_cost']); 

you have an extra paranthesis

Also change this

while($row = mysql_fetch_array($result))

to

while($row = mysql_fetch_assoc($result))
Sign up to request clarification or add additional context in comments.

2 Comments

Though when I add rows to the DB only the original rows I had are being reflected.. Odd
Are you sure they are added to the orders table in the same db?
0

I think you need to change third line to:

result = mysql_query($sql) or die(mysql_error());

(space before "or")

1 Comment

Thanks for the suggestion, but this had no effect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.