SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    Christoph, if that's the case then you can do something like:
    PHP Code:
    <?php
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $variable2=$period*25.00;
              echo 
    'Registration fee: '.$variable2;
    }
    ?>
    You say it's not displaying the cost as a double? that's odd.... Let me think.

    Additionally, I thought of something. Remember I said something about scope a moment ago? This could be your problem. Try something like this:
    PHP Code:
    <?php
    $x_Amount2
    =0.00;
    switch(
    $period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.$variable2;
    }
    // then assign $total_cost=$x_Amount2; and see what happens
    ?>
    Any difference?

    -Colin
    This does not work. How do I add case 1 - 10? That's probably where I screwed up!?

    PHP Code:
    $x_Amount2=0.00;
    switch(
    $period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.$variable2;

    // then assign $total_cost=$x_Amount2; and see what happens

    case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.$x_Amount2;
              
    $total_cost=$x_Amount2;
              break;


  2. #27
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    Another idea! Are you passing the variable correctly? Newer versions of PHP have register_globals set to off, so you need to pass variables across scripts with either $_GET['variablename'] or $_POST['variablename'] instead of just $variablename. Just another idea.

    -Colin
    I am not sure if I can follow you. Where and how would I set this in my case? My form method is set to post.

  3. #28
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    I wasn't aware that could be done. However, case 1: case 2: ... case 10: is not bad coding style at all. Technically, that's the right way.
    Yep, that was my point too
    case 1: case 2: case 3: etc == the right way
    case $i <= 10: == the bad way

  4. #29
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    I WISH I COULD THINK OF EVERYTHING AT THE SAME TIME.

    I know how to solve your problem with the 25.00 being turned to 25. Use settype() like so:
    PHP Code:
    <?php
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $variable2=settype($period,"float")*25.00;
              echo 
    'Registration fee: '.$variable2;
    }
    ?>


    -Colin
    Hm, still does display the twenty five as "25" not "25.00"

    PHP Code:
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=settype($period,"float")*25.00;
              echo 
    'Registration fee: '.$x_Amount2;


    // then assign $total_cost=$x_Amount2; and see what happens

    case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10:
              
    $x_Amount2=settype($period,"float")*25.00;
              echo 
    'Registration fee: '.$x_Amount2;
              
    $total_cost=$x_Amount2;
              break;

    Sorry for being such a pain ....

    Christoph

  5. #30
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Christoph
    ... This does not work. How do I add case 1 - 10? That's probably where I screwed up!? ...
    Sorry, that was a typo. Should be:
    PHP Code:
    $x_Amount2=0.00;
    switch(
    $period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.$x_Amount2;

    To find out if you have register_globals set to on, run this script:
    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    Look in there to see if it's set to on or off. If it's on, then you don't need to modify anything. If it's set to off, you'll need to change the variables passed to the processing script to $_POST['variablename'] in the processing script.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  6. #31
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem - I really appreciate your help!!!!!!!!!!!

    register_globals is turned on.

    In regards to the typo - I tried the latest code change you posted but still see the "25" - does the "float" part needs to be added maybe?

    Man, sometimes I hate myself that my programming skills are so bad - especially when it comes to the really complicated stuff.

    Christoph

  7. #32
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by jofa
    Yep, that was my point too
    case 1: case 2: case 3: etc == the right way
    case $i <= 10: == the bad way
    Hehe -- cool beans.
    Originally posted by Christoph
    Hm, still does display the twenty five as "25" not "25.00" ... Sorry for being such a pain ....
    PHP Code:
    <?php
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.settype($x_Amount2,"float");
    }
    You're not being a pain. Try that?

    Blargh -- you're not necessarily bad at programming! I mean -- look at me. I can't figure out why 25.00 won't display!

    -Colin
    Last edited by Aes; Jan 2, 2003 at 22:30.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  8. #33
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Aes
    I can't figure out why 25.00 won't display!
    number_format($x_Amount2, 2) maybe?

  9. #34
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hehe - Colin - I am learning a lot already. So, I guess that's good. It is just frustrating sometimes but on the other side - I usually are not giving up on those things.

    Anyway - your latest code displays "1"

    Jofa - where would I need to add your statement to give it a shot?

    Christoph

  10. #35
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jofa's da' man.
    PHP Code:
    <?php
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*25.00;
              echo 
    'Registration fee: '.number_format($x_Amount2,2);
    }
    ?>
    Try that.

    -Colin
    Last edited by Aes; Jan 2, 2003 at 22:48.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  11. #36
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Christoph
    Jofa - where would I need to add your statement to give it a shot?
    echo 'Registration fee: '.number_format($x_Amount2, 2);

  12. #37
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeehaaaa! You guys are awesome! So, that part is working!

    Still haven't figured out the other thing why the variable is not being recognized by authorize.net. I just tried again - same error message in regards to the amount.

    Christoph

  13. #38
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need a break. I really appreciate your help so far!!!!!!! If you have any ideas about the other issue - please let me know. I'll try again tomorrow!

    Thanks!!!!

    Christoph

  14. #39
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try running $total_amount through jofa's number_format() function. See you later.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  15. #40
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright - here we go again.

    I did a test to see if the variable gets transmitted from the order form to authorize.net process php file. In that process file I added if statements

    PHP Code:
    if ($x_Amount2 25) {  $x_Amount3 "25";  }
    if (
    $x_Amount2 50) {  $x_Amount3 "50"; }
    if (
    $x_Amount2 75) {  $x_Amount3 "75";  }
    if (
    $x_Amount2 100) {  $x_Amount3 "100"; } 
    ... and so on. I then assigned the new variable "$x_Amount3" properly.

    This seems to work as I now get a success code back from authorize.net. So, I think the variable is transmitted to the next step

    BUT

    when the order amount is $25.00 (which is displayed properly on the order form) the process file does not stop at the first if statement and continues all the way through all if statements - therefore processing the highest amount available.

    So, this is where I am. I can successfully process orders but with the wrong amount. Any idea how that can be solved?

    Christoph

  16. #41
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you're asking if 25.00 is equal to 25, it's going to return false. Let's start anew. We can solve this bugger. Instead of dealing with integers at all, lets only deal with floats.

    Wait, you say $x_Amount3 works. That's a String, you know. Maybe authorize.net uses Strings. Try assigning the values into Strings (e.g. instead of 25.00 use "25.00"). Does that make any difference?

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  17. #42
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the code in the order form to

    PHP Code:
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=$period*"25.00";
              echo 
    'Registration fee: '.number_format($x_Amount2,2); 
    Please note the "25.00" instead of just 25.00 ! I also removed my former code changes to the process file and have the same issue again - the amount charged is not valid.

    I wonder why it partially works when I put it into the process file but then runs through all the if statements instead of accepting the condition when it is met?!

    Christoph

  18. #43
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't multiply an integer by a String. Try this:
    PHP Code:
    <?php
    switch($period){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         default:
              
    $x_Amount2=number_format($period*25,2)."";
              echo 
    "Registration fee: {$x_Amount2}";
    }
    ?>
    Give that ago. Also, just for your benefit:
    PHP Code:
    <?php
    $x_Amount2
    ="25.00";
    if(
    $x_Amount2==25// false
    if($x_Amount2==50// false
    ...
    ?>
    Do you see why that doesn't work? Try something like:
    PHP Code:
    <?php
    $x_Amount2
    ="25.00";
    if(
    $x_Amount2=="25.00"// true
    if($x_Amount2=="50.00"// false
    ...
    ?>
    See if any of those work. (It would work in Java)! I'm going to go read about Strings at php.net in the mean time.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  19. #44
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Not a valid amount"

    This is so weird.

  20. #45
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo() $x_Amount2 on both scripts and see what it displays.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  21. #46
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The order form displays

    75.00

    and the process file does not display anything for this variable at all.

    Christoph

  22. #47
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Christoph
    The order form displays

    75.00

    and the process file does not display anything for this variable at all.

    Christoph
    It does not make sense. I added it to the part where it prints the error message.



    PHP Code:
    {
            
    // Credit Card Error (returned from authorizenet)
            
    $error .= "We're sorry, but your credit card information was not accepted .  Please re-check the credit card type, number, and expiration date you entered." {$x_Amount2};
        } 
    I guess that is wrong?

  23. #48
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried different variations with the echo command but none returned anything (only a couple of parse errors).

    Anyway - I wonder if we could use the

    str_replace

    functionality?

  24. #49
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Update:

    Many hours later I got it to work!!!!

    I added this to the order form behind the first 'echo' for displaying the $ Amount!

    PHP Code:
    echo '<input type="hidden" name="x_Amount2" value="'number_format($x_Amount2,2),'" />'
    Then I added this into the process file for authorize.net

    PHP Code:
    switch($x_Amount2){
         case 
    0:
              print 
    'Please select a registration period!';
              break;
         
    case 
    25: case 50: case 75: case 100: case 125: case 150: case 175: case 200: case 225: case 250:
              
    $x_Amount3=$x_Amount2;
              break;

    It is finally working the way I want it and the way I need it! Thank you very much for your help!!!!!!!!!!

    Christoph (now working on the passback parameter stuff )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •