473,381 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

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
2 2212
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Whitfield | last post by:
Hi All... I am a beginning .NET developer and am using C# with ASP.NET. I am having trouble with switch statements, can anyone help? When I run the below code, I receive an error "Compiler Error...
13
by: webzila | last post by:
Hello, I have to write a program for an 8051 micro-controller using micro-C to monitor Switch 1 and if the switch in pushed the message "switch 1 pushed" should be displayed in the LCD. Also the...
9
by: Steve Bering | last post by:
I am a csharp newbie and am trying to work through some code and have gotten myself stuck in a loop. Any help would be appreciated. I have the following code in place: public IDcCommand...
13
by: Adam Blair | last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time error is raised if not all values within the Enum are handled in the switch statement? I realise you can use default:...
4
by: OutdoorGuy | last post by:
Greetings, I was wondering if it is possible to test for a range of values in a "Switch" statement? I have the following code, but it is generating an error when I attempt to compile it. Any...
14
by: serrand | last post by:
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ... without using a goto... and if possible without using an auxiliary variable as i did... int res;...
9
by: Raj | last post by:
public static void HandleException(ref Exception io_exException, bool i_blnPropagateException) { switch (true) { case io_exException is ApplicationHandledException: { if...
4
by: huzzaa | last post by:
I am using a switch statement that will decide from a random number what message to display. I want the random number to be between 0 and 100 and then if the number is say between 1 and 10 to...
6
by: asadikhan | last post by:
Hello, I have a bit of a design issue around this application I am developing, and I just want to run it through some of the brains out here. So I have a table called ErrorCheck which...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.