Solved

Fill in Questions

Posted on 2002-04-01
2
221 Views
Last Modified: 2013-12-03
please correct the following code, i can't seem to know what's wrong with it:
<html>
<head>
<body>
<font size="5">Here is your question    </font> (The correct answer is in <font color="#008000"> green </font>)
<BR>
<font face="Arial">
<BR><BR><BR>
<? for ($m=0;$m<strlen($Content);$m++) {
    if ($Content[$m] != "#")
    echo $Content[$m];
    elseif
    ?><INPUT TYPE="text" NAME="answer" VALUE="" SIZE="15" ><?
}
?>
<BR><BR>
<?
  if ($answer1 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer1;?> </font>
<BR>
<?}
  if ($answer2 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer2;?> </font>
<BR>
<?}
  if ($answer3 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer3;?> </font>
<BR>
<?}
  if ($answer4 != "") {
?>
<font color="#008000" face="Arial"> <?echo $answer4;?> </font>
<BR>
<?}
?>
<BR><BR>Difficulty Level             <font color="#008000"><? echo $Difficulty_Level ?></font>
<BR>Restricted Question    <font color="#008000">
<? if ($Private=="Y")
{
?>
Yes
<? } else {
?>
No
<?
}
?>
</font>
</body>
</head>
</html>
0
Comment
Question by:almaha
2 Comments
 
LVL 5

Expert Comment

by:andriv
ID: 6910885
Your error is with the elseif, if you use elseif you need an argument:

elseif(codition)

Change it to:

else{

This way it's either the if or the else.

0
 
LVL 5

Accepted Solution

by:
dkjariwala earned 50 total points
ID: 6912504
Check this code out,

<html>
<head>
<body>
<font size="5">Here is your question    </font> (The correct answer is in <font color="#008000"> green
</font>)
<BR>
<font face="Arial">
<BR><BR><BR>
<?php
     
function put_answer($answer)
{
     print "<font color=\"#008000\" face=\"Arial\"> $answer3</font>";
}
     
?>
<?
     for ($m=0;$m<strlen($Content);$m++)
     {
        if ($Content[$m] != "#")
               echo $Content[$m];
        elseif(YOUR CONDTION HERE) ///////// You need to Provide your condition here. Or choose else, instead of elseif
     {
             ?><INPUT TYPE="text" NAME="answer" VALUE="" SIZE="15" ><?
     }
?>
<BR><BR>
<?
 if (!empty($answer1))
          put_answer($answer1);

 if (!empty($answer2))
          put_answer($answer2);

 if (!empty($answer3))
          put_answer($answer3);

 if (!empty($answer4))
          put_answer($answer4);
?>

<BR><BR>Difficulty Level             <font color="#008000"><? echo $Difficulty_Level ?></font>
<BR>Restricted Question    <font color="#008000">
<?
     
     if ($Private=="Y")
          print "Yes";
     else
          print "No";

?>


</font>
</body>
</head>
</html>

You need to specify elseif condition.

Specify that or I guess you just need to use ELSE. instead of Elseif.

You are escaping in/out of PHP mode bit too much and unnecessarily. I mean you just want to print one HTML and you are escaping to HTML for that.

See this code, it is much more organized and readable.

JD
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question