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

Recommended Answers

All 4 Replies

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;

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

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

Thanks all who have helped me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.