switch statment problem

[php]switch ($x)
{
case 1:
echo “Number 1”;
break;
case 2:
echo “Number 2”;
break;
case 3:
echo “Number 3”;
break;
default:
echo “No number between 1 and 3”;
}[/php]

I tried this code but switch ($x) this line get an error what is the wrong with this.
pls help

What error message did you get? Probably you have an error above this switch statement block (like missing semicolon, or closing quite/double quote, etc.)

[php]$product_name = “Processors”;

switch ($product_name)
{
case “Video Cards”:
echo “Video cards range from $50 to $500”;
break;
case “Monitors”:
echo “LCD monitors range from $200 to $400”;
break;
case “Processors”:
echo “Intel processors range from $100 to $1000”;
break;
default:
echo “Sorry, we don’t carry $product_name in our catalog”;
break;
}[/php]

I did another example that also same. that error msg shows "Parse error: parse error, expecting ','' or‘;’’ in C:\wamp\www\Fahim\4.switch stat.php on line 36 "

36 line statement is $product_name = “Processors”;

The bug is above the line 36, not shown here.

If you paste the php code again, please use the “php” button in the toolbar above the text box whre you enter your post.

I am really sorry. I missed semi colon (;), I really sorry… Thank for your reply. It is very good for the beginners.

Sponsor our Newsletter | Privacy Policy | Terms of Service