Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:22:51+00:00 2026-06-15T21:22:51+00:00

I am fairly new to the whole programming thing, so forgive me if this

  • 0

I am fairly new to the whole programming thing, so forgive me if this is a stupid question. It seems odd that I haven’t run into it before.

I am trying to make an order form for a cake. You fill out the form, submit it, and it will then display the order in a new window, where you then hit “submit,” and upload it to the Database. I have a series of If Statements to check for errors in the form before submitting it. Here is a simplified version of the code. Writing means any writing you want on the cake, Name is your name, and cake is what type of cake you want (the default is “None”).

try {
$name = trim($params->name);
$cake = trim($params->cake);
$writing = trim($params->writing);
if (strlen($name) < 3){
    throw new Exception("Please enter Your name.");
    }
if ($cake = "None") {
        throw new Exception("Please select a Cake"
     }
if ($cake = "Caramel Apple Pie" or $cake = "Pumpkin Pie" or $cake = "Eggnog Pie" and strlen($writing) > 1) {
    throw new Exception("We are sorry, but you can't write on any of our specialty pies.");
    }

} catch(Exception $x) {
    $error = $x->getmessage();
    }

So what is happening is that when I go and hit submit the first time, the correct cake type comes up, but when you submit it the second time, the error comes up saying that I have “None” selected. All the other values are there and remain the same. I think the problem is that the first “IF” statement (Where it says “If($cake = “None”)) is automatically changing $cake to “None” because I have tried commenting just that statement out, and it will then change the cake to be “Caramel Apple Pie,” which is in the top of the next IF statement.

Anyone know why it is doing this? And how to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:22:53+00:00Added an answer on June 15, 2026 at 9:22 pm

    You are using a = instead of a ==

    • = is an assignment operator, ie it changes our variable value. Using it inside an if-statement results in setting the variable and checking the result.
    • == is a comparison operation
    • === is also a comparison operator, it additionally checks whether the types are equal.

    See the PHP assignment operator and comparison operator manuals for more information

    Additional notes:

    • the line throw new Exception("Please select a Cake" is missing ); as well.
    • using exceptions to write a message in $error is a bit overkill in your example situation! For example, just use $error = "Please enter Your name.".
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new at the whole Android thing so I am hoping this
I'm fairly new to this whole web-development thing (2 weeks maybe, my 1st scraping
I am fairly new to a objective-c or in whole mac/iphone development. My question
I'm fairly new to the whole n-tier architecture thing, and I had some questions
I'm fairly new to OO programming specifically with Java. I have a question pertaining
I am fairly new to programming and trying to resolve this problem. I have
Im fairly new to the whole world of iPhone dev so forgive me if
I've got a BindingSource for a DataSet. I'm fairly new to this whole binding
I am fairly new to programming and while doing a lot of reading this
I'm fairly new to Qt. This is my second 'real' program that I'm writing.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.