467,104 Members | 1,094 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

Switch Error Message help

Hi,

I am trying to create a switch but I do not know why I am geting an
error message, can someone tell me what is wrong,

Error Message;

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/home/natuk/public_html/php/order-server.php on line 2

Parse error: parse error in
/home/natuk/public_html/php/order-server.php on line 2

my script is as follows;

<?php

switch ( $server )
{
case "celeron_special_5":
case "celeron_special_6":

$monthly_price = 89.99 AND $setup =19.99 ;
break;

case "p4_special_1":
case "p4_special_2":

$monthly_price = 99.99 AND $setup = 19.99;
break;

}
$total = $server + $monthly;
echo "your monthly cost is $monthly_price and your setup cost is
$setup. Your total cost for first month is $total ";
?>

Thanks for any help.

Hong
Jul 16 '05 #1
  • viewed: 1994
Share:
2 Replies
"Hong" <ho**********@yahoo.co.uk> wrote in message
news:7a**************************@posting.google.c om...
Hi,

I am trying to create a switch but I do not know why I am geting an
error message, can someone tell me what is wrong,

Error Message;

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/home/natuk/public_html/php/order-server.php on line 2

Parse error: parse error in
/home/natuk/public_html/php/order-server.php on line 2

my script is as follows;

<?php

switch ( $server )
{
case "celeron_special_5":
case "celeron_special_6":

$monthly_price = 89.99 AND $setup =19.99 ;
break;

case "p4_special_1":
case "p4_special_2":

$monthly_price = 99.99 AND $setup = 19.99;
break;

}
$total = $server + $monthly;
echo "your monthly cost is $monthly_price and your setup cost is
$setup. Your total cost for first month is $total ";
?>

Thanks for any help.

Hong


Could be all those spaces between switch and ( $server ). Try taking those
out.
Jul 16 '05 #2
On 15 Sep 2003 23:56:02 -0700, ho**********@yahoo.co.uk (Hong) wrote:
I am trying to create a switch but I do not know why I am geting an
error message, can someone tell me what is wrong,

Error Message;

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/home/natuk/public_html/php/order-server.php on line 2
Yet that character isn't in the code you posted.

Are you sure this is the same code? With the $server variable filled in, and
the other mistake further down corrected, this runs fine on my server.

What PHP version?
How are you running it?

Most hits from a Google search show similar messages appearing in some
circumstances when running an old version of PHP as CGI.
Parse error: parse error in
/home/natuk/public_html/php/order-server.php on line 2

my script is as follows;

<?php

switch ( $server )
Where is $server defined? Looks like you're relying on register_globals = on.
{
case "celeron_special_5":
case "celeron_special_6":

$monthly_price = 89.99 AND $setup =19.99 ;
Weird use of AND here.

$monthly_price = 89.99;
$setup = 19.99;
Also be very wary of using floating point numbers for money; due to the way
computers work, they are approximations, and will lose accuracy the more
calculations you do with them. Use integers multiplied up to the minor currency
unit (or fraction of, if relevant). e.g.

$monthly_price = 8999;
$setup = 1999;

And only divide back down (here by 100) when displaying.
break;

case "p4_special_1":
case "p4_special_2":

$monthly_price = 99.99 AND $setup = 19.99;
break;

}
$total = $server + $monthly;


Where is $monthly defined? Did you mean $monthly_price?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by David Whitfield | last post: by
13 posts views Thread by webzila | last post: by
9 posts views Thread by Steve Bering | last post: by
13 posts views Thread by Adam Blair | last post: by
14 posts views Thread by serrand | last post: by
4 posts views Thread by huzzaa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.