0

Hi all,
I have a problem with string comparisions
for ex; this fucntion

$id=$_GET['id'];
if(isset($id) && $id=benelli){
echo "benelli text";
}
if(isset($id) && $id=bettinsoli){
echo "bettinsoli text";
}

i do like above
but when i got id via URL to go benelli text
it writes both benelli text and bettinsoli text
i would like to go only ones text. but it displays both
thanks in advance

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by azegurb
0

Your If statements should be in the form:

if(isset($id) && $id == benelli){

Notice the == to test for equality. A single = in an IF will act the same as a statement like $a = $b;

Edited by chrishea: n/a

0

strings should be enclosed with quotes, single or double

if(isset($id) && $id=="benelli")

and also the equals sign "=" is an assignment operator, not an equality operator used for comparison, use the equality operator "==" instead

Edited by vaultdweller123: n/a

0
$id=$_GET['id'];
if(isset($id)){
  if ($id=='benelli') 
     echo "benelli text";
  else 
     echo "bettinsoli text";
}

Edited by rajarajan07: n/a

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.