Jump to content

nawtwrong

Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nawtwrong's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have an e-commerce script that works perfectly in internet explorer/firefox/netscape on any windows OS but when I use the script in Opera on windows (or in IE/Safari on a Mac I've been told) the sessions don't work. What should happen is 5 sessions are set at the login stage: [code]$_SESSION['login']; $_SESSION['products']; $_SESSION['total']; $_SESSION['product_codes']; $_SESSION['country_code'];[/code] These are set on a 'shared' secure server (https://shared_secure_server_space/mydomain/). Don't know if it's anything to do with this? Like I say in internet explorer/firefox/netscape the sessions carry over from the login page right through to the order added page with no problems. In Opera/safari etc something wierd happens, sometimes they work, other times they are not set at all and on the rare occasions they do work, when you refresh a page they disappear! This happens randomly, there is no pattern to it or anything I can spot that should be causing it. I have tried clearing the cache of the browser to see if that was it, but it still happens. Has anyone has similar experiences or can offer any helpful advice, I'd really appreciate it because it's driving me mad. Thanks in advance for any help.
  2. Thanks for your reply. I've got the majority of this code working now, however for some reason, when I round certain numbers up or down I get the same number from the list, for example: [code]function my_round_down($n,$a){     sort($a);     $out=$a[0];     for ($i=0;$i<count($a);$i++) {         if ($a[$i]<$n){             $out=$a[$i];         }     }     return $out; } function my_round($n,$a) {     sort($a);     $out=$a[0];     $p=abs($n-$out);     for ($i=1;$i<count($a);$i++) {         if (abs($a[$i]-$n)<=$p) {             $out=$a[$i];             $p=abs($n-$out);         }     }     return $out; } $number = 6987; //Or whatever number has been submitted from a form $pre=array(5000,10000,15000,25000,50000,75000,100000,125000,200000,300000,400000,500000, 1500000); $new_number_rounded_down = my_round_down($number,$pre); $new_number_rounded_up = my_round($number,$pre); echo $new_number_rounded_down; //Gives 5000 echo $new_number_rounded_up; //Gives 5000 (should give 10000)[/code] If I swap $number for something like 92000 it gives the correct lower and higher rounded numbers. I've had a look but not sure what i'm doing wrong. Any ideas? Thanks
  3. Right, sorted it. I put some code in to work out whether or not rounded down or rounded up was needed and called this right at the beginning og the parent script: This seems to have done the trick. Thanks again for your help!
  4. I've got the code working how I need it to, but there's just one problem: "Fatal error: Cannot redeclare my_round_down()" I'm excecuting this code using [code]include("../code.php");[/code] inside a while loop which is what's causing the error. However, I've tried using require_once, this clears the error message, but causes the function to do the same thing to [i]all[/i] the values that need rounding in the while loop. Is there a way round this? The my_round_down() function (exactly as above) needs to run for each number in a while loop and round each number individually. Thanks
  5. Thanks for replying, some very useful info there. I'll let you know how I get on. Thanks again!!
  6. I have a list of pre determined numbers set as variables, I need a way of rounding these numbers to the nearest high or lower match in that list, to a number that a visitor will type in: For example there will be a form with an input box for a number that the user types in. This will be submitted to a script where each of the pre-determined numbers in the list mentioned above will be stored as variables: $number_1 = 1000 $number_2 = 2000 $number_3 = 3000 $number_4 = 4000 $number_5 = 10,000 etc The user might type in a number like 2921, so the script would need to round this [b]up[/b] to 3000 ($number_3) the next highest in the list above. I also want another script that would round the number [b]down[/b] so 9999 would be rounded down to 4000 ($number_4) the next lowest in the list above. Is there a nice, simple way of doing this? I was thinking the numbers for the list could be stored in an array and maybe I could use the round() function, but I've no idea where to start. Any advive or suggestions greatly appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.