By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,613 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

Switch Error Message help

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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.