0

I have a database on PHPMyAdmin, named mydb, then a table named myguests. Its supposed to access the information on the database and display it. Here is my code:

<?php
$connection = mysql_connect('localhost', 'root', '');
mysql_select_db('mydb');

$query = "SELECT * FROM myguests";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
echo "Name: " . $row["firstname"]. " " . $row["lastname"].;
}

mysql_close();
?>  

When I go to display the webpage it says

Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\printback.php on line 10

Anyone have a solution?

Thanks for helping me!

2 Answers2

0

This line:

echo "Name: " . $row["firstname"]. " " . $row["lastname"].;

Has a dot right before the semicolon. Remove it and it'll work.

Eduardo Galván
  • 962
  • 7
  • 15
0

Remove the .(dot) sign after $row["lastname"]

// Creates a loop to loop through results
while($row = mysql_fetch_array($result)){   
    echo "Name: " . $row["firstname"]. " " . $row["lastname"];
}
Egg
  • 1,782
  • 1
  • 12
  • 28
Kirit
  • 52
  • 4