0

I am trying to write some code that will simply return a value of someone's name, followed by 3 test scores. In my head, the code should look simply like this:

<html>
<head>
<title> PHP Scores</title>
</head>
<body>
<?php

  echo "<p>",$_GET["name"],"</p>";
  echo "<p>",$_GET["test1"],"</p>";
  echo "<p>",$_GET["test2"],"</p>";
  echo "<p>",$_GET["test3"],"</p>";

?>
</body>
</html>

Now, whenever I type in the URL: http://localhost/phpassignment1.php?name=john&test1=88&test2=74&test3=100

It only returns the value of the name. Is there any reason why I am not getting the 3 test scores to be echoed onto the page?

Timothy G.
  • 6,335
  • 7
  • 30
  • 46
D day
  • 27
  • 5

1 Answers1

0

Your PHP syntax is wrong for joins. You need to use . instead of ,.

echo "<p>",$_GET["name"],"</p>";
echo "<p>",$_GET["test1"],"</p>";
echo "<p>",$_GET["test2"],"</p>";
echo "<p>",$_GET["test3"],"</p>";

Should be:

echo "<p>" . $_GET["name"] . "</p>";
echo "<p>" . $_GET["test1"] . "</p>";
echo "<p>" . $_GET["test2"] . "</p>";
echo "<p>" . $_GET["test3"] . "</p>";

Hope this helps!

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71