473,385 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

syntax error, unexpected T_ELSE

Hi

I have produced the code below however I am getting the error in the title and have no idea what it means, I think its the only thing stopping the code from running. Any help please! Ive been looking for ages and I cannt find the mistake!
Expand|Select|Wrap|Line Numbers
  1. <title> Grade Point Converter </title>
  2. </head>
  3. <body>
  4. <h1>Use the form below to work out your grade point</h1>
  5. <br>
  6. <form method="post" action=" <?echo $_SERVER[ "PHP_SELF" ]?>">
  7. Grade: 
  8. <input type="text" Name="grade"> % <br> 
  9. Convert from <br>
  10. <Input type = 'Radio' Name ='scale' Value= 'Undergraduate' checked>
  11. Undergraduate Modular Framework Awards <br>
  12. <Input type = 'Radio' Name ='scale' Value= 'HND'>
  13. HND - Current Scheme <br>
  14. <Input type = 'Radio' Name ='scale' Value = 'Masters'>
  15. Masters
  16. <P>
  17. <Input type = "Submit" Name = "Submit" Value = "Submit grade">
  18. </form>
  19.  
  20. <?PHP
  21.  
  22. if (isset($_POST['Submit'])) {
  23. //actions when form is submited to post to itself
  24. $grade = $_POST['grade'];
  25. $scale = $_POST['scale'];
  26. // actions define $grade and $scale for use later
  27. if ($scale=='Undergraduate') 
  28. // Identifies the selection as undergraduate
  29. $a=$grade;
  30. $b="";
  31. if ($a >= 70){
  32.    $b = "13 - 15 which is a First Class Honours";
  33. }elseif ($a >= 60){
  34.    $b = "10 - 12 which is a Upper Second Class Honours";
  35. }elseif ($a >= 50){
  36.    $b = "7 - 9 which is a Lower Second Class Honours";
  37. }elseif ($a >= 40){
  38.    $b = "4 - 6 which is a Third Class Honours";
  39. }else{
  40.    $b = "0 - 3 which is a Fail";
  41. }
  42. echo " $a % is equal to grade point  $b using the undergraduate modular framework";
  43.  
  44. }
  45. else if ($scale=='HND')
  46. // Identifies the selection as HND
  47. $a=$grade;
  48. $b="";
  49. if ($a >= 70){
  50.    $b = "13 - 15 which is a Distinction";
  51. }elseif ($a >= 53){
  52.    $b = "8 - 12 which is a Merit";
  53. }elseif ($a >= 40){
  54.    $b = "4 - 7 which is a Pass";
  55. }else{
  56.    $b = "1 - 3 which is a Fail";
  57. }
  58. echo " $a % is equal to grade point  $b using the HND framework";
  59.  
  60. else if($scale=='Masters')
  61. // Identifies the selection as Masters
  62. $a=$grade;
  63. $b="";
  64. if ($a >= 70){
  65.    $b = "13 - 15 which is a Distinction";
  66. }elseif ($a >= 60){
  67.    $b = "10 - 12 which is a Merit";
  68. }elseif ($a >= 50){
  69.    $b = "7 - 9 which is a Pass";
  70. }elseif ($a >= 40){
  71.     $b = "4 - 6 which is a Compensatable Failure";
  72. }else{
  73.    $b = "1 - 3 which is a Fail";
  74. }
  75. echo " $a % is equal to grade point  $b using the Masters framework";
  76.  
  77. }
  78. ?>
  79. </body>
  80. </html>
  81.  
Oct 29 '07 #1
2 5842
brettl
41
It looks like you are having a little trouble with your if else statements. Give the code below a try :
Expand|Select|Wrap|Line Numbers
  1. <title> Grade Point Converter </title>
  2. </head>
  3. <body>
  4. <h1>Use the form below to work out your grade point</h1>
  5. <br>
  6. <form method="post" action=" <?echo $_SERVER[ "PHP_SELF" ]?>">
  7. Grade:
  8. <input type="text" Name="grade"> % <br>
  9. Convert from <br>
  10. <Input type = 'Radio' Name ='scale' Value= 'Undergraduate' checked>
  11. Undergraduate Modular Framework Awards <br>
  12. <Input type = 'Radio' Name ='scale' Value= 'HND'>
  13. HND - Current Scheme <br>
  14. <Input type = 'Radio' Name ='scale' Value = 'Masters'>
  15. Masters
  16. <P>
  17. <Input type = "Submit" Name = "Submit" Value = "Submit grade">
  18. </form>
  19.  
  20. <?PHP
  21.  
  22. if (isset($_POST['Submit'])) {
  23. //actions when form is submited to post to itself
  24. $grade = $_POST['grade'];
  25. $scale = $_POST['scale'];
  26. // actions define $grade and $scale for use later
  27. }else {
  28.     echo 'submit failed';
  29. }
  30.  
  31. if ($scale=='Undergraduate'){
  32. // Identifies the selection as undergraduate
  33. $a=$grade;
  34. $b="";
  35. if ($a >= 70){
  36. $b = "13 - 15 which is a First Class Honours";
  37. }elseif ($a >= 60){
  38. $b = "10 - 12 which is a Upper Second Class Honours";
  39. }elseif ($a >= 50){
  40. $b = "7 - 9 which is a Lower Second Class Honours";
  41. }elseif ($a >= 40){
  42. $b = "4 - 6 which is a Third Class Honours";
  43. }else{
  44. $b = "0 - 3 which is a Fail";
  45. }
  46. echo " $a % is equal to grade point $b using the undergraduate modular framework";
  47.  
  48. }
  49. else if ($scale=='HND'){
  50. // Identifies the selection as HND
  51. $a=$grade;
  52. $b="";
  53. if ($a >= 70){
  54. $b = "13 - 15 which is a Distinction";
  55. }elseif ($a >= 53){
  56. $b = "8 - 12 which is a Merit";
  57. }elseif ($a >= 40){
  58. $b = "4 - 7 which is a Pass";
  59. }else{
  60. $b = "1 - 3 which is a Fail";
  61. }
  62. echo " $a % is equal to grade point $b using the HND framework";
  63. }
  64. else if($scale=='Masters'){
  65. // Identifies the selection as Masters
  66. $a=$grade;
  67. $b="";
  68. if ($a >= 70){
  69. $b = "13 - 15 which is a Distinction";
  70. }elseif ($a >= 60){
  71. $b = "10 - 12 which is a Merit";
  72. }elseif ($a >= 50){
  73. $b = "7 - 9 which is a Pass";
  74. }elseif ($a >= 40){
  75. $b = "4 - 6 which is a Compensatable Failure";
  76. }else{
  77. $b = "1 - 3 which is a Fail";
  78. }
  79. echo " $a % is equal to grade point $b using the Masters framework";
  80.  
  81. }
  82. ?>
  83. </body>
  84. </html>
  85.  
I hope this helps.
Oct 29 '07 #2
ak1dnar
1,584 Expert 1GB
Hi Bex, Welcome to TheScripts.com.
Forum Tips

Please use CODE tags as described in here when Posting source codes.
Oct 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
1
by: MLH | last post by:
I have an A97 application with a form (frmEditOwners). Here's a code snippet for deleting current record... Private Sub DelOwnerRecBtn_Click() On Error GoTo Err_btnCloseOwnerEditForm_Click...
4
kestrel
by: kestrel | last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on. Heres what i have <?php...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
5
by: goodguyjam | last post by:
Hi I'm trying to apply user authentication with HTTP on my site but i get the above error. Can anyone say whats wrong?? I cant figure it out. Here's my code below: <?php /* Program: Auth.php *...
1
by: sheenrose | last post by:
<? $uname = $_REQUEST; $pass = $_REQUEST; /*Connecting, selecting database */ $LogStatus = 0; $link = mysql_connect("localhost","root","kushal") or die();
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.