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

  • SEARCH
  • Home
  • 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 8295087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:27:40+00:00 2026-06-08T14:27:40+00:00

There is probably a very simple fix to this, but i’m all new with

  • 0

There is probably a very simple fix to this, but i’m all new with php, and very ignorant.
I’ve been trying to get my head around this problem, but to no avail.
Here is the code :

echo $slot['slot_type'];
echo "<br><br>";
if ($slot['slot_type']='tree')          echo "This place is full of life, and can be used for hunting, gathering, logging, or other activities.";
if ($slot['slot_type']='town_hall')     echo "The town hall houses the governors, and is propriety of the King.";
if ($slot['slot_type']='farm1')     echo "Townspeople attempt to grow a selection of wild plants on these crops, hoping for a steady food supply.";
if ($slot['slot_type']='farm2')     echo "Farming is hard work, but a full storehouse of food is a great comfort.";

The first line with echo $slot['slot_type']; was my attempt to try and understand why my “if” statement does not work. However, it prints the proper string, in this case “tree”.

So, in practise, instead of printing one of the proposed text strings, the browser prints all four of them, as if it ignored my IF statements completely. Again, sorry for asking what looks like such a silly question.

  • 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-08T14:27:41+00:00Added an answer on June 8, 2026 at 2:27 pm

    You need to change all your single = to == or some other logical check.

    What you are essentially doing is assigning $slot['slot_type'] the values on the right hand side of your condition which will always return true.

    Have a read of the php manual here http://uk.php.net/manual/en/language.operators.php

    As an aside, your if structures might be better created using a switch statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to VBscript so there is probably a very simple solution to this.
There is probably a very simple answer to this question, but I can't for
there is probably a very simple answer to this very simple question, but i
There is probably a very simple answer to this, but I want to be
There is probably a very simple way of doing this, but this is a
Sorry, I'm new to Java and there's probably a very simple answer to this.
This is probably a very simple problem but I'm trying to create an array
I'm new to nuget and this is probably a very simple question but I
There's probably a very simple reason for this, but when hydrating an object I'm
There is probably a very simple solution to this but my jQuery skills are

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.