Using Functions

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML XMLNS="http://www.w3.org/1999/xhtml">
  <HEAD>
    <TITLE>
      Untitled
    </TITLE>
    <META HTTP-EQUIV="generator" CONTENT="PHP Designer 2005" />
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK=
  "#800080" ALINK="#FF0000">
    <?php

     /* If $radio (the action variable) is multiply then mutliply */
    if ($radio="multiply")
       {
       $number1 * $number2 == $answer
       print $answer
       }
    /* If $radio is divide then divide */
    elseif ($radio="divide")
     {
      $number1 / $number2 == $answer
      print $answer
    else
       {print This is not programmed yet}

    ?>
  </BODY>
</HTML>

How do I get that code to work. I know there are many errors but what am I doing wrong my php parser shows nothign wrong when I do a debug so I think it is broekn. I think you can tell what I want so how do I get it to do the divide and multiple using functions?
LVL 5
SkyvanManAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arantiusCommented:
SkyvanMan,
> my php parser shows nothign wrong
There is very much wrong.  You're not running the parser properly.  You're missing semicolons at the end of your statements.  Operators cannot appear on the left hand side of an assignment, and the assignment operator is =, == is the comparison operator.
0
arantiusCommented:
SkyvanMan,
>   {print This is not programmed yet}
You also need quotes around strings.  This should be

print "This is not programmed yet";
0
b_locoCommented:
There were a lot of errors.

Here is the corrected code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML XMLNS="http://www.w3.org/1999/xhtml">
  <HEAD>
    <TITLE>
      Untitled
    </TITLE>
    <META HTTP-EQUIV="generator" CONTENT="PHP Designer 2005" />
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK=
  "#800080" ALINK="#FF0000">
    <?php

     /* If $radio (the action variable) is multiply then mutliply */
    if ($radio=="multiply"){
       $answer = $number1 * $number2;
       print $answer;
      } elseif ($radio=="divide"){
       $answer = $number1 / $number2;
       print $answer;
    } else{
            print "This is not programmed yet";
      }

    ?>
  </BODY>
</HTML>

I should say that this does nothing!
You don't have the $radio variable set.

However, if I understand what you are doing this should work:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML XMLNS="http://www.w3.org/1999/xhtml">
  <HEAD>
    <TITLE>
      Untitled
    </TITLE>
    <META HTTP-EQUIV="generator" CONTENT="PHP Designer 2005" />
  </HEAD>
  <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK=
  "#800080" ALINK="#FF0000">
    <?php

     /* If $radio (the action variable) is multiply then mutliply */
    if ($_POST['radio']=="multiply"){
       $answer = $_POST['number1'] * $_POST['number2'];
       print $answer;
      } elseif ($_POST['radio']=="divide"){
       $answer = $_POST['number1'] / $_POST['number2'];
       print $answer;
    } else{
            print "<form method=\"POST\" action=\"".$PHP_SELF."\">
                        Multiply?<input type=\"radio\" name=\"radio\" value=\"multiply\">
                        Divide?<input type=\"radio\" name=\"radio\" value=\"divide\"><br>
                        Number 1 <input type=\"text\" name=\"number1\">
                        Number 2 <input type=\"text\" name=\"number2\">
                        <input type=\"submit\" value=\"Go\">
                        </form>";
      }

    ?>
  </BODY>
</HTML>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SkyvanManAuthor Commented:
Thank you all so much. I knew I was forgettin a lot of stuff. I am really new to PHP as you can see.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.