PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
DJJester
Forum Newbie
Posts: 8 Joined: Sun Apr 06, 2008 6:31 am
Post
by DJJester » Sun Apr 06, 2008 9:25 am
Hey again group,
I've got this error now and I've gone through and fixed up a few of the {} encapsulation errors I've made, but can't see any more that PHP is telling me there is... can anyone else see it?
Code: Select all
<?php
// this starts the session
session_start();
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="Text/css" href="/stdtheme.css" />
</HEAD>
<?php
If (isset($Page)) {
If ($Page > 2) {
$to = "<email>";
$subject = "<subject>";
$txt = "<txt>";
$header = "<from>";
mail($to,$subject,$txt,$headers);
echo "Thanks for participating. Your results have now been emailed.";
exit("Goodbye");
}
elseif ($Page > 1) {
$questions = split(':', $_POST["QuestionID"]);
foreach ($questions as $id) {
$_SESSION["answers"] .= $id . ":" . $_POST['$id'] . "#";
}
}
writeQandA($Page);
echo '<A HREF=/"<address>?page=&' . ($Page + 1) . '/">';
echo "Next Page</A>";
}
else {
echo "Welcome....<BR><BR>";
echo '<A HREF=/"http://testing.logisofttech.com/index.php?page=1 . '/">';
echo 'Begin!<' . $chr(47) . 'A>';
}
function writeQandA($page)
{
echo '<FORM Action=\"<address>\" Method=\"POST\">';
If ($page = 1) {
echo 'Question 1: ';
echo 'This will be multiple choice, on page 1';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=\"checkbox\" name=\"0\" value=\"1\">';
echo 'First answer to multiple';
echo '<' . $chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=\"checkbox\" name=\"0\" value=\"2\">';
echo 'Second Answer to multiple';
echo '<' . $chr(47) . 'TD>';
}
If ($page = 2) {
echo 'Question 2: ';
echo 'This will be a single, on page 2';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=\"radio\" name=\"1\" value=\"1\">';
echo 'This is the answer to the single q.';
echo '<' . $chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=\"radio\" name=\"1\" value=\"2\">';
echo 'This is the next answer to the single';
echo '<' . $chr(47) . 'TD>';
}
echo '<' . $chr(47) . 'TABLE>';
echo '<input type=\"hidden\" name=\"QuestionID\" value=\"' . '1:3' . '\">';
echo '<' . $chr(47) . 'FORM>';
}
?>
</HTML>
Oh man, if anyone can help me get this page to finally show will be my hero!
Cheers,
Jess.
Last edited by
John Cartwright on Sun Apr 06, 2008 9:54 am, edited 1 time in total.
Reason: Please use [code=php][/code] tags when posting php code
khushbush
Forum Commoner
Posts: 99 Joined: Tue Mar 11, 2008 11:50 am
Post
by khushbush » Sun Apr 06, 2008 9:42 am
You needed to remove the single quote at the end of the hyperlink on line 33.
Code: Select all
<?php
// this starts the session
session_start();
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="Text/css" href="/stdtheme.css" />
</HEAD>
<?php
If (isset($Page)) {
If ($Page > 2) {
$to = "<email>";
$subject = "<subject>";
$txt = "<txt>";
$header = "<from>";
mail($to,$subject,$txt,$headers);
echo "Thanks for participating. Your results have now been emailed.";
exit("Goodbye");
}
elseif ($Page > 1) {
$questions = split(':', $_POST["QuestionID"]);
foreach ($questions as $id) {
$_SESSION["answers"] .= $id . ":" . $_POST['$id'] . "#";
}
}
writeQandA($Page);
echo '<A HREF=/"<address>?page=&' . ($Page + 1) . '/">';
echo "Next Page</A>";
}
else {
echo "Welcome....<BR><BR>";
[color=#FF0000]echo '<A HREF=/"http://testing.logisofttech.com/index.php?page=1 ./">';[/color]
echo 'Begin!<' . $chr(47) . 'A>';
}
function writeQandA($page)
{
echo '<FORM Action=\"<address>\" Method=\"POST\">';
If ($page = 1) {
echo 'Question 1: ';
echo 'This will be multiple choice, on page 1';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=\"checkbox\" name=\"0\" value=\"1\">';
echo 'First answer to multiple';
echo '<' . $chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=\"checkbox\" name=\"0\" value=\"2\">';
echo 'Second Answer to multiple';
echo '<' . $chr(47) . 'TD>';
}
If ($page = 2) {
echo 'Question 2: ';
echo 'This will be a single, on page 2';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=\"radio\" name=\"1\" value=\"1\">';
echo 'This is the answer to the single q.';
echo '<' . $chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=\"radio\" name=\"1\" value=\"2\">';
echo 'This is the next answer to the single';
echo '<' . $chr(47) . 'TD>';
}
echo '<' . $chr(47) . 'TABLE>';
echo '<input type=\"hidden\" name=\"QuestionID\" value=\"' . '1:3' . '\">';
echo '<' . $chr(47) . 'FORM>';
}
?>
</HTML>
Copy and paste the code above, then tell me what you get.
DJJester
Forum Newbie
Posts: 8 Joined: Sun Apr 06, 2008 6:31 am
Post
by DJJester » Sun Apr 06, 2008 4:03 pm
Ahhh! Cheers!!
I found that the double quotes wern't necessary as well, so I just used the single quotes around the address.
Also, I had used $chr instead of just chr - woops
Thanks again!
Jess.
khushbush
Forum Commoner
Posts: 99 Joined: Tue Mar 11, 2008 11:50 am
Post
by khushbush » Sun Apr 06, 2008 4:13 pm
You're welcome
If you're not using a php editor, then it would be a good idea to download one where you can keep track of all your brackets, curly brackets, quotes, etc.
I find using PSPad quite easy...not quite what the more experienced PHP users would recommend (I'm a newbie!)
http://www.pspad.com/
It's saved me a TONNE of hassle!