Jump to content

NOOBIE HELP!!!


Jubs2U

Recommended Posts

I'm a beginner with PHP, I'm working on an online class project.  I have written a "quiz" and I have to follow up with an answer page.  I have it written but when the score button is selected and my answer page appears, it appears in code.  Can someone please look at it and tell me what is wrong.  ???

 

Thank You

Jubs

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Great Explorers Quiz</title>
<meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="php_styles.css"
type="text/css" />
</head>

<body>
<h1>Quiz Results</h1>

<?php
function scoreQuestions() {
}
if (count($_GET) == 5) {
}
else
     echo "You did not answer all the questions!  Click your browser's Back button to return to the quiz.";

echo "<p>Question 1: ", $_GET["question1"];
     if ($_GET["question1"] =="b")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

echo "<p>Question 2: ", $_GET["question2"];
     if ($_GET["question2"] =="d")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

echo "<p>Question 3: ", $_GET["question3"];
     if ($_GET["question3"] =="a")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

echo "<p>Question 4: ", $_GET["question4"];
     if ($_GET["question4"] =="b")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

echo "<p>Question 5: ", $_GET["question5"];
     if ($_GET["question5"] =="c")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

</body>
</html>

Link to comment
Share on other sites

number of things that might effect.  um, you havent closed your php tages.  your function is empty, containing or doing nothing, and not being called so why have it there?

 

also, im not sure whether or not your ifs etc should have theire braces and semicolons, i alwasy do no matter what for readability.  also, the meta tagsa and stuff at the top may be causeing the oage fo simply read as html or sml, and ignoging "foreign" tages such as php

 

 

have a look into it

 

sorry i cant find an instant error

 

Link to comment
Share on other sites

echo "<p>Question 1: ", $_GET["question1"];
 

Should be

echo "<p>Question 1:" . $_GET["question1"];
[/quote]

And so on for all your similar echo statements.  As far as I know anyway, I don't think you can separate echo blocks by comma's.

And what the previous poster said, a function won't do anything unless you call it later on the page somewhere

Link to comment
Share on other sites

echo "<p>Question 5: ", $_GET["question5"];
     if ($_GET["question5"] =="c")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";

</body>
</html>

 

Where are you terminating the PHP code? Should be:

 

echo "<p>Question 5: ", $_GET["question5"];
     if ($_GET["question5"] =="c")
echo " (Correct!)</p>";
     else
echo " (Incorrect)</p>";
?>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.