Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Fill in Questions

Posted on 2002-04-01
2
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
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 dynamically set the form action using jQuery.

722 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