Jump to content

Displaying a PHP/MYSQL Table - Error?


colleyboy

Recommended Posts

Hi, 

 

I am trying to array a mysql tables data into a php table.

 

Not having luck...

 

<?php

 

include('dbconnect.php')

 

?>

 

 

<?php
// Make a MySQL Connection
$query = "SELECT * FROM cars"; 

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


while($row = mysql_fetch_array($result)){
echo $row['CarName']. " - ". $row['CarTitle'];
echo "<br />";

echo "<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=100%>";
echo "<TR />";
echo "<TD />";
echo $row['CarName'].;
echo "</TD>";
echo "<TD />";
echo $row['CarTitle'].;
echo "</TD>";

echo "</TR>";
echo "</TABLE>";

}
?>

 

 

Error says: Parse error: syntax error, unexpected ';' in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/viewcars.php on line 69

 

echo </TD /> is line 69.

 

Please help :D

 

Ian

Link to comment
https://forums.phpfreaks.com/topic/213604-displaying-a-phpmysql-table-error/
Share on other sites

If you're trying to display a literal decimal or period, you need to quote it and concatenate it to the variable, otherwise it can just go away . . .

 

echo $row['CarName'].; // <-- HERE
echo "</TD>";
echo "<TD />";  
echo $row['CarTitle'].; // <-- AND HERE

oy! you beat me to it as I went to test it out first!

 

Anyways, you said:

 

echo </TD /> is line 69

 

According to what you pasted to us, there is no such line in your code. Though, what was said above me will fix that error.

 

Well, now that you mention it, <TR /> and <TD /> aren't valid syntax. <tr></tr> and <td></td> are valid . . .

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.