Current location: Hot Scripts Forums » Programming Languages » PHP » Please check this and help!


Please check this and help!

Reply
  #1 (permalink)  
Old 10-05-06, 08:46 PM
leeprice2006 leeprice2006 is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Please check this and help!

I am new to PHP and I wrote this...

PHP Code:

<?php

$cost 
25;
$type $_REQUEST["Type"];

if (
$type == "Business")
    
$cost 10;
elseif (
$type == "Personal")
    
$cost 5;

echo 
"Total Price:" " £" $cost
?>
But for some reason "Total Price: £25" always shows regardless of if I select Business or Personal. Please help I have tried everything... its probably something really simple.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-05-06, 10:58 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you post your code that is sending the value to this code you can probably get an answer quicker, but I'll take a guess - The form sending this probably has a variable name type instead of Type.

Edit: Another guess might be that the value being sent to this code is business/personal instead of Business/Personal.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???

Last edited by mab; 10-05-06 at 11:04 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-06-06, 01:59 AM
Tim Mousel Tim Mousel is offline
Wannabe Coder
 
Join Date: Jan 2005
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
This code works:

PHP Code:

<?php
$cost 
25;
$type $_REQUEST["Type"];

if (
$type == "Business"
   
$cost $cost 10;

elseif (
$type == "Personal"
   
$cost $cost 5;

echo 
"Total Price:" " £" $cost
?>
You need to assign the new value to $cost.

Tim
__________________
Five Star Review Script - Add reviews to your website!
Mixed Martial Arts - Learn the fastest growing martial art
Women's Self-Defense - Courses and DVDs available
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-06-06, 03:50 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
You could also use:
PHP Code:

$cost += 10;

// ...which is identical to:
$cost $cost 10
...etc.
__________________
The toxic ZCE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-06-06, 03:51 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Topic moved to PHP.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-06-06, 07:30 AM
leeprice2006 leeprice2006 is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks works fine!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 10-06-06, 08:01 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
LOL. I guess after you proofread so many bogus lines of code in a forum, you go blind...
PHP Code:

 $cost 10
 
$cost 5
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Art Nexus seeking PHP programmers TheArtNexus Job Offers & Assistance 5 02-26-08 04:08 AM
Help cmottershead ASP.NET 3 11-15-04 01:10 AM
Someone Help, This Is Getting Aggravating Ice_Metal PHP 3 01-30-04 11:37 PM
PHP Help & Suggestions Needed cpwalton Job Offers & Assistance 2 01-26-04 05:39 PM


All times are GMT -5. The time now is 09:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.