Jump to content

allie.nicole

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

allie.nicole's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Now no errors, but blank page once 'Get Score' is selected on northcarolina.html. Code is below: <?php error_reporting(E_ALL); ini_set('display_errors', true); $score=0; if(isset($_POST['submit'])) { } if ($_POST['no1'] =="B") { $score += 10; } else { $errors[] = "The American Dogwood is the state flower of NC."; } if ($_POST['no2'] =="false") { $score += 10; } else { $errors[] = "False. The state bird of NC is the cardinal."; } if($_POST['no3'] =="C") { $score += 10; } else { $errors[] = "Raleigh is the capital of NC."; } if($_POST['no4'] == "true") { $score += 10; } if($_POST['no5'] == "D") { $score += 10; } if($_POST['no6'] == "true") { $score += 10; } if($_POST['no7'] == "A") { $score += 10; } else { $errors[] = "Though all of these are mountain ranges, the Appalachians is the only one found in NC."; } if($_POST['no8'] == "A") { $score += 10; } else { $errors[] = "The historical marine base, Cherry Point, is located in the town of Havelock, NC."; } if($_POST['no9'] == "true") { $score += 10; } else { $errors[] = "Tobacco is one of the leading industries in NC. Others include chemical products and textiles."; } if($_POST['no10'] == "C") { $score += 10; } else { $errors[] = "Charlotte is the largest city in NC."; echo" Your score on the All About North Carolina quiz is ".$score; } ?>
  2. I have done a bit more work on the PHP file - I decided to make it simpler by removing all of the HTML. Once I did that, I no longer get the same error, but this error appears instead: Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in C:\wamp\www\quizresults.php on line 82 It looks like Line 82 is a couple of lines below the closing tag of the code. After my edits, my code looks like this: <?php phpinfo(); ?> <?php $score=0; if(isset($_POST['submit'])) { } if ($_POST['no1'] =="B") { $score += 10; } else { $errors[] = "The American Dogwood is the state flower of NC."; } if ($_POST['no2'] =="false") { $score += 10; } else { $errors[] = "False. The state bird of NC is the cardinal."; } if($_POST['no3'] =="C") { $score += 10; } else { $errors[] = "Raleigh is the capital of NC."; } if($_POST['no4'] == "true") { $score += 10; } if($_POST['no5'] == "D") { $score += 10; } if($_POST['no6'] == "true") { $score += 10; } if($_POST['no7'] == "A") { $score += 10; } else { $errors[] = "Though all of these are mountain ranges, the Appalachians is the only one found in NC."; } if($_POST['no8'] == "A") { $score += 10; } else { $errors[] = "The historical marine base, Cherry Point, is located in the town of Havelock, NC."; } if($_POST['no9'] == "true") { $score += 10; } else { $errors[] = "Tobacco is one of the leading industries in NC. Others include chemical products and textiles."; } if($_POST['no10'] == "C") { $score += 10; } else { $errors[] = "Charlotte is the largest city in NC."; } "Your score on the All About North Carolina quiz is ".$score."; ?> In addition to removing all HTML, I have double-checked that all of my brackets have an open and close. Based on what I have learned so far, everything looks to be consistent, but apparently my browser is expecting something else. Hopefully, I didn't create any more issues with the edits I did, and it is just a simple fix that I don't recognize because I am not yet too familiar with PHP. Does anyone have an idea regarding why I cannot get rid of this error?
  3. Again, I have modified my PHP code to correct what seemed to be the issue by choosing to remove all HTML code. It still seems that I am getting "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\quizresults.php" on line 106, which is contained in this section of code: if($_POST['no10'] == "C") { $score += 10; } else { $errors[] = "Charlotte is the largest city in NC. "; } echo " Your score on the "All About North Carolina" quiz is ".$score."; foreach($errors as $error) echo $error . "<br />\n"; ?> </HTML> In particular, Line 106 reads: Your score on the "All About North Carolina" quiz is ".$score."; Is anyone able to spot an error that has been made that I am obviously overlooking? I have exhausted the little knowledge of PHP that I have in addition to all of my known resources, but can't seem to get this corrected. Any suggestions would be greatly appreciated.
  4. So, I have edited the code for the PHP file once again, and when trying to view it, I get this error: Parse error: syntax error, unexpected '<' in C:\wamp\www\quizresults.php on line 103. After looking at Line 103, it looks like the only thing that line contains is a piece of code for a paragraph break. I am assuming that this isn't it, but that it lies near the referenced line somewhere. Can someone else spot what the problem might be based on the code below? <?php phpinfo(); ?> <HTML> <h2>'How Much Do You Know About North Carolina?' Quiz Results:</h2> <?php $score=0; if(isset($_POST['submit'])) { } if ($_POST['no1'] =="B") { $score += 10; } else { $errors[] = "The <strong>American Dogwood</strong> is the state flower of NC."; } if ($_POST['no2'] =="false") { $score += 10; } else { $errors[] = "False. The state bird of NC is the <strong>cardinal</strong>."; } if($_POST['no3'] =="C") { $score += 10; } else { $errors[] = "<strong>Raleigh</strong> is the capital of NC."; } if($_POST['no4'] == "true") { $score += 10; if($_POST['no5'] == "D") { $score += 10; if($_POST['no6'] == "true") { $score += 10; if($_POST['no7'] == "A") { $score += 10; } else { $errors[] = "Though all of these are mountain ranges, the <strong>Appalachians</strong> is the only one found in NC. "; } if($_POST['no8'] == "A") { $score += 10; } else { $errors[] = "The historical marine base, Cherry Point, is located in the town of <strong>Havelock, NC</strong>. "; } if($_POST['no9'] == "true") { $score += 10; } else { $errors[] = "Tobacco <strong>is</strong> one of the leading industries in NC. Others include chemical products and textiles. "; } if($_POST['no10'] == "C") { $score += 10; } else { $errors[] = "<strong>Charlotte</strong> is the largest city in NC. "; } <P> <P> echo " <strong>Your score on the "All About North Carolina" quiz is ".$score."</strong> "; foreach($errors as $error) echo $error . "<br />\n"; ?> </HTML> Thanks!
  5. I've finished a rough draft of the PHP page, based on your advice and some other research that I've done online. I believe I must have some things incorrect, because I'm still unable to view the results, but whether or not it's entirely correct, I believe it represents a decent idea of what I'd like to accomplish. Below is the code: <HTML> <h2>'How Much Do You Know About North Carolina?' Quiz Results:</h2> </HTML> <?php $score=0; if(isset($_POST['submit'])) { } If ($no1="B") $score=$score+10; else { echo "The <strong>American Dogwood</strong> is the state flower of NC. "; } If ($no2="false") $score=$score+10; else { echo "False. The state bird of NC is the <strong>cardinal</strong>. "; } If($no3="C") $score=$score+10; else { echo "<strong>Raleigh</strong> is the capital of NC. "; } If($no4="true") $score=$score+10; If($no5="D") $score=$score+10; If($no6="true") $score=$score+10; If($no7="A") $score=$score+10; else { echo "Though all of these are mountain ranges, the <strong>Appalachians</strong> is the only one found in NC. "; } If($no8="A") $score=$score+10; else { echo "The historical marine base, Cherry Point, is located in the town of <strong>Havelock, NC</strong>. "; } If($no9="true") $score=$score+10; else { echo "Tobacco <strong>is</strong> one of the leading industries in NC. Others include chemical products and textiles. "; } If($no10="C") $score=$score+10; else { echo "<strong>Charlotte</strong> is the largest city in NC. "; } <P> <P> <strong>Your score on the "All About North Carolina" quiz is ".$score." "; ?>
  6. Hi Zane, At first, I thought that <br /> was the correct way to enter it, but then again I wasn't sure if it made much difference - regardless, I have corrected that. I looked back over my last post, and it looks like I accidentally left out the line of code that creates my 'Submit' button - sorry about that. I know that the <li> tags will be put on another line, but I entered the <br> to put an additional line between each of the questions so that it wouldn't look so crowded. Is there a better way to do this? I've removed the code for the first form and linked the existing one to quizresults.php. Also, I have completed the code for all of the quiz questions. My final HTML page looks something like this: <html> <head> <title>All About North Carolina!</title> </head> <body bgcolor="lightblue"> <img src=http://www.vincecartersanctuary.org/Portals/61544/images//NCSateFlag.jpg align="right" height="100" width="100" alt="Official Flag of the State of NC"/> <h2>North Carolina</h2> <h3><blockquote>"Every kid - no matter where he or she lives in NC - must graduate from high school with what it really takes to succeed in a career, in a two- or four-year college or in Technical training."</blockquote><br/> <P ALIGN="RIGHT">- NC Governor Beverly Perdue</h3> <P><P><em>Interested in learning more about Governor Perdue and what she has done for the people of North Carolina? <a href="http://www.state.nc.us"><b>Click here</a></b> to visit the Official Web Site of the State of NC.</em></P></P> <P> <P> <B><blockquote>How well do you know your facts about North Carolina? Take this trivia quiz for fun! Select the best answer for each question, then click 'Submit' to see your score.</B></blockquote> <P> <form action='quizresults.php' method='POST'> <ol> <li>What is the state flower of North Carolina?<br/> <input type="radio" value="A" name="no1"> A. Poppy<br/> <input type="radio" value="B" name="no1"> B. American Dogwood<br/> <input type="radio" value="C" name="no1"> C. Black-Eyed Susan<br/> <input type="radio" value="D" name="no1"> D. Bluebonnet<br/> </li> <br/> <li>The state bird of North Carolina is the Robin.<br/> <input type="radio" value="true" name="no2">True<br/> <input type="radio" value="false" name="no2">False<br/> </li> <br/> <li>What is the capital city of North Carolina?<br/> <input type="radio" value="A" name="no3"> A. Charlotte<br/> <input type="radio" value="B" name="no3"> B. Winston-Salem<br/> <input type="radio" value="C" name="no3"> C. Raleigh<br/> <input type="radio" value="D" name="no3"> D. Greenville<br> </li> <br/> <li>North Carolina has 100 counties in total.<br/> <input type="radio" value="true" name="no4">True<br/> <input type="radio" value="false" name="no4">False<br/> </li> <br/> <li>Which of these is a major river in North Carolina?<br/> <input type="radio" value="A" name="no5"> A. Roanoke<br/> <input type="radio" value="B" name="no5"> B. Neuse<br/> <input type="radio" value="C" name="no5"> C. Yadkin<br/> <input type="radio" value="D" name="no5"> D. All of the above<br/> </li> <br/> <li>Virginia is a bordering state of North Carolina.<br/> <input type="radio" value="true" name="no6">True<br/> <input type="radio" value="false" name="no6">False<br/> </li> <br/> <li>Name a mountain range in North Carolina.<br/> <input type="radio" value="A" name="no7"> A. Appalachians<br/> <input type="radio" value="B" name="no7"> B. Rockies<br/> <input type="radio" value="C" name="no7"> C. Adirondacks<br/> <input type="radio" value="D" name="no7"> D. Cascades<br/> </li> <br/> <li>In what city/town is the famous marine base "Cherry Point" located?<br/> <input type="radio" value="A" name="no8"> A.Havelock, NC<br/> <input type="radiO" value="B" name="no8"> B.Goldsboro, NC<br/> <input type="radio" value="C" name="no8"> C.Wilmington, NC<br/> <input type="radio" value="D" name="no8"> D.New Bern, NC<br/> </li> <br/> <li>Tobacco is <b>one</b> of the leading industries in the state.<br/> <input type="radio" value="true" name="no9">True<br/> <input type="radio" value="true" name="no9">False<br/> </li> <br/> <li>What is the <em>largest</em> city in North Carolina?<br/> <input type="radio" value="A" name="no10"> A. Concord<br/> <input type="radio" value="B" name="no10"> B. Greensboro<br/> <input type="radio" value="C" name="no10"> C. Charlotte<br/> <input type="radio" value="D" name="no10"> D. Fayetteville<br/> </li> </ol> <P> <input type='submit' name='submit' value='Get Score'/> </body> </html> I am now back to working on the PHP portion. I found some code from a couple of websites that suggests how to create the quiz results page, but it doesn't seem that I'm doing it quite right because it doesn't generate correctly. I will continue to work on this and post an update when I have made more progress. In a private message, I will send you a link to both my northcarolina.html page in addition to the attempted work that I have done thus far with quizresults.php.
  7. Thanks for the tutorial. I have worked on the HTML page a bit more, and I have decided to create a quiz on random facts about North Carolina. So far, I have created the code for most of the questions (I believe I will be using about 10, and I have created 7 so far). I also have my 'Submit' button in place. I am now at the stage where I'd like to be able to have the quiz scored automatically. Once the 'Get Score' button is clicked, I want to have the results of the quiz displayed on the PHP page. Below is the code that I have finished so far on the HTML page: <html> <head> <title>All About North Carolina!</title> </head> <body bgcolor="lightblue"> <img src=http://www.vincecartersanctuary.org/Portals/61544/images//NCSateFlag.jpg align="right" height="100" width="100" alt="Official Flag of the State of NC"/> <h2>North Carolina</h2> <h3><blockquote>"Every kid - no matter where he or she lives in NC - must graduate from high school with what it really takes to succeed in a career, in a two- or four-year college or in Technical training."</blockquote><br/> <P ALIGN="RIGHT">- NC Governor Beverly Perdue</h3> <P><P><em>Interested in learning more about Governor Perdue and what she has done for the people of North Carolina? <a href="http://www.state.nc.us"><b>Click here</a></b> to visit the Official Web Site of the State of NC.</em></P></P> <P> <blockquote>Have you enjoyed the tidbits of information provided here about the Tar Heel State? If so, take the opportunity to gather even more facts! Subscribe to our mailing list to receive our weekly newsletter that contains the latest news about North Carolina in addition to interesting articles and stunning photos that have been submitted by our readers. Simply enter your name and e-mail address below to sign up!</blockquote> <P> <form action='quizresults.php' method='POST'> <span>Name:</span><input type='text' name='name' /> <span>Email:</span><input type='text' name='email' /> <input type='submit' value="Submit"/> </form> <P> <P> <P> <B>How well do you know your facts about North Carolina? Take this trivia quiz for fun! Select the best answer for each question, then click 'Submit' to see your score.</B> <P> <form action='NorthCarolina.php' method='POST'> <ol> <li>What is the state flower of North Carolina?<br> <input type="radio" value="A" name="no1"> A. Poppy<br> <input type="radio" value="B" name="no1"> B. American Dogwood<br> <input type="radio" value="C" name="no1"> C. Black-Eyed Susan<br> <input type="radio" value="D" name="no1"> D. Bluebonnet<br> </li> <br> <li>The state bird of North Carolina is the Robin.<br> <input type="radio" value="true" name="no2">True<br> <input type="radio" value="false" name="no2">False<br> </li> <br> <li>What is the capital city of North Carolina?<br> <input type="radio" value="A" name="no3"> A. Charlotte<br> <input type="radio" value="B" name="no3"> B. Winston-Salem<br> <input type="radio" value="C" name="no3"> C. Raleigh<br> <input type="radio" value="D" name="no3"> D. Greenville<br> </li> <br> <li>What is the <em>largest</em> city in North Carolina?<br> <input type="radio" value="A" name="no4"> A. Murphy<br> <input type="radio" value="B" name="no4"> B. Hayesville<br> <input type="radio" value="C" name="no4"> C. Charlotte<br> <input type="radio" value="D" name="no4"> D. Concord<br> </li> <br> <li>Which of these is a major river in North Carolina?<br> <input type="radio" value="A" name="no5"> A. Roanoke<br> <input type="radio" value="B" name="no5"> B. Neuse<br> <input type="radio" value="C" name="no5"> C. Yadkin<br> <input type="radio" value="D" name="no5"> D. All of the above<br> </li> <br> <li>Virginia is a bordering state of North Carolina.<br> <input type="radio" value="true" name="no6">True<br> <input type="radio" value="false" name="no6">False<br> </li> <br> <li>Name a mountain range in North Carolina.<br> <input type="radio" value="A" name="no7"> A. Appalachians<br> <input type="radio" value="B" name="no7"> B. Rockies<br> <input type="radio" value="C" name="no7"> C. Adirondacks<br> <input type="radio" value="D" name="no7"> D. Cascades<br> </li> <br> It looks like everything on the HTML page is correct so far, and I believe that my 'Get Score' button directs to the proper page so far. I am thinking about removing the name and e-mail fields. Do you have any suggestions on how to get started on the PHP side of things? Thanks! When you post code, please put it in between <-- code tags -->
  8. Zane, Below is the HTML coding that I used to create northcarolina.html: <html> <head> <title>All About North Carolina!</title> </head> <body> <img src=http://www.vincecartersanctuary.org/Portals/61544/images//NCSateFlag.jpg align="right" height="100" width="100" alt="Official Flag of the State of NC"/> <h2>North Carolina</h2> <h3><blockquote>"Every kid - no matter where he or she lives in NC - must graduate from high school with what it really takes to succeed in a career, in a two- or four-year college or in Technical training."</blockquote><br/> <P ALIGN="RIGHT">- NC Governor Beverly Perdue</h3> <P><P><em>Interested in learning more about Governor Perdue and what she has done for the people of North Carolina? <a href="http://www.state.nc.us"><b>Click here</a></b> to visit the Official Web Site of the State of NC.</em></P></P> <body bgcolor="lightblue"> </body> </html> As I mentioned previously, I have only created a fairly simple page so far. EDITed for tags.
  9. Hi everyone! So, I have recently become interested in the world of webpage design and HTML coding. Thus far, I have created a few simple HTML webpages, the first of which includes some basic facts and information on the state of NC. Everything has gone rather smoothly for me until this point, but I would now like to incorporate a bit of PHP into my knowledge of web development. First, I would like to include a form on my NC page that once submitted, goes to a new PHP page displaying the inputted data to the screen. On the new page, I am attempting to include files: a header and footer. On my other couple of pages for which I would like to add server side includes. And lastly, if possible, it would be great if I could learn how to add some additional features like sending e-mails or displaying the date. Any advice or tips on how to go about this would be greatly appreciated!
×
×
  • 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.