Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Kris Larsen
Kris Larsen
8,015 Points

Why get i this error? Parse error: syntax error, unexpected 'border' (T_STRING) in /home/treehouse/workspace/table.p

<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { padding: 5px; } </style> </head> <body> <table> <tr> <th>ID</th> <th>Reference</th> <th>Price</th> </tr> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </table> </body> </html>

<?php $conn = mysql_connect("10.11.3.104","root","password"); if (!$conn) { die("Can not connect: " . mysql_error()); } mysql_select_db("dury", $conn); $sql = "select products.id, products.reference, products.price from products; $myData = mysql_query($conn, $sql) or die (mysql_error($conn)); echo "<table border=1> <tr> <th>id</th> <th>reference</th> <th>price</th> </tr>"; while($row = mysql_fetch_array($myData)) { echo "<tr>"; echo "<td>" . $record["products_id"] . "</td>"; echo "<td>" . $record["products_reference"] . "</td>"; echo "<td>" . $record["products_price"] . "</td>"; echo "</tr>"; } echo "</table>";

$myData->close();

mysql_close($conn);

?>

1 Answer

Matthew Brock
Matthew Brock
16,791 Points
<?php
$conn = mysql_connect("10.11.3.104","root","password"); 
if (!$conn) { 
  die("Can not connect: " . mysql_error()); 
} 
mysql_select_db("dury", $conn); 

/* missing ending quote on this line */
$sql = "select products.id, products.reference, products.price from products"; 


$myData = mysql_query($conn, $sql) or die (mysql_error($conn)); 

echo "id reference price "; 

while($row = mysql_fetch_array($myData)) { 
  echo ""; 
  echo "" . $record["products_id"] . ""; 
  echo "" . $record["products_reference"] . ""; 
  echo "" . $record["products_price"] . ""; 
  echo ""; 
} 
echo "";
$myData->close();
mysql_close($conn);
?>