Solved

Fill in Questions

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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.
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…

864 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

18 Experts available now in Live!

Get 1:1 Help Now