Solved

Fill in Questions

Posted on 2002-04-01
2
201 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now