can anyone tell me why the code bellow wont work? it's some problem down when i try to echo out html :/ $sql = "SELECT * FROM flash ORDER BY date DESC LIMIT 10"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo "<table border="1" width="100%">"; echo "<tr>"; echo "<td>" $row["name"]; "</td>"; echo "<td>" $row["size"]; "</td>"; echo "<td>" $row["date"]; "</td>"; echo "<td> </td>"; echo "<td> </td>"; echo "</tr>"; echo "</table>"; echo "<p>"; } <? mysql_free_result($result); ?> PHP:
The error is in three echo statements for your table data. They should be corrected to be: echo "<td>" . $row["name"] . "</td>"; echo "<td>" . $row["size"] . "</td>"; echo "<td>" . $row["date"] . "</td>"; Code (markup):
Thank you, but i still get a parse error :/ Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /index.php on line 23 i cant se that i missed any ;
make sure you end with ?> your first sample was: } <? mysql_free_result($result); ?> no close php before the next open php tag --
He's not escape quotes on this line: echo "<table border="1" width="100%">"; try : echo "<table border=\"1\" width=\"100%\">"; or echo '<table border="1" width="100%">';