473,396 Members | 1,895 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,396 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 2215
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.