0

Hi there,

I'm struggling to get a simple if statement to work. I am passing a country though to a page from a previous page ( ?country=Poland)
and then trying to evaluate it and display a specific bit of text if the country is for example'Germany'. Here's what I have:

<?php 
    	if ($_Get["country"]  = 'Germany') { echo "Company Name: Susensoftware AG<br />Contact Name: Axel Susen<br /><br />"; }
  ?>

But it is displaying the text even if the country isn't 'Germany' and I don't know why?!

Please laugh if I'm being dumb, but can anyone help?

Thanks in advance

2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by nav33n
0

Oops...

$_Get ["country"] = 'Germany' is setting it to Germany, not just evaluating the IF... so perhaps I need to set a variable and evaluate that instead...?

Am I on the right lines? Anybody ;)

0

:P Yeps! That's absolutely right!

= is an assignment operator where as, == is a comparison operator!

Edited by nav33n: n/a

0

Thanks for the help! I added the extra "=" and used a variable and it worked properly:

$cvalue = $_GET["country"];
    	if ($cvalue  == 'Germany') { echo "Company Name: Susensoftware AG<br />Contact Name: Axel Susen<br /><br />"; }
if($_GET['country'] == "Germany")

You are missing another "=" in your statement.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.