Jump to content
Larry Ullman's Book Forums

Paul

Members
  • Content count

    147
  • Joined

  • Last visited

  • Days Won

    1

Paul last won the day on April 17 2013

Paul had the most liked content!

Community Reputation

6 Neutral

About Paul

  • Rank
    Advanced Member
  1. Thanks HartleySan for the suggestion. I'm away at the weekend so other things need doing. I'll try it when I can and get back to you. Thanks again. Paul
  2. Hi HartleySan, Thanks for the answer. 1. The $curtain_price_total was initialised, it was at the top of the page and I didn't include it. $curtain_price_total = 0; 2. I changed the code to $curtain_price_total += (int)$cur_v; It didn't work unfortunately. I did think about adding the '(int)' within the foreach but some of the values are strings. Thanks anyway. Paul
  3. Hi rob, Thanks for the answer. I tried removing the 'float' part of the number_format code and it made no difference. I take your point though, I can see why it wouldn't be needed. I'll bear that in mind and change it where I've used it in other areas. However, if it were a formatting issue then would that make the 'curtain_price_total' variable incorrect? Cheers Paul
  4. Hi all, I'm querying a DB for basket contents. I'm then using a foreach to display and then add the totals togethor. The grand total is then being displayed below the list of items in the basket. All pretty standard stuff. However if the amount of one of the items in the basket is greater that 999 it just counts the number of thousands, i.e. £1,245.60 will be counted as 1. £2,842.70 is counted as 2. £22,168.50 is counted as 22. Relevant code foreach ($_SESSION['curtain_basket'] as $curtain_title => $curtain_value) { echo'<tr>'; foreach ($curtain_value as $cur_t => $cur_v) { echo' <td><p>'. $cur_v . '</p></td> '; } echo' <td><input name="curtain_remove" type="checkbox" value="' . $curtain_title . '" /></td> <td><p class="tiny_text">Remove?</p></td> </tr>'; echo'</br>'; //Display the delivery total, the artwork total and grand total. $curtain_price_total += $cur_v; } echo'<h3>Total for curtains: &pound '. number_format((float)$curtain_price_total, 2, '.', '').'</h3>'; Relevant debugging info [curtain_basket] => Array ( [0] => Array ( [Curtain Type] => Handmade triple pleat buckram heading [Track or pole width] => 500 [Finished length of the curtain (drop)] => 500 [Type of lining] => Blackout [Fullness] => Normal (double fullness) [Interlined] => No [Fabric width] => 139 [The final quote] => 662.00 ) [1] => Array ( [Curtain Type] => Handmade triple pleat buckram heading [Track or pole width] => 1000 [Finished length of the curtain (drop)] => 1000 [Type of lining] => Blackout [Fullness] => Normal (double fullness) [Interlined] => Yes [Fabric width] => 139 [The final quote] => 2,615.70 ) [2] => Array ( [Curtain Type] => Handmade triple pleat buckram heading [Track or pole width] => 5000 [Finished length of the curtain (drop)] => 5000 [Type of lining] => Blackout [Fullness] => Normal (double fullness) [Interlined] => No [Fabric width] => 139 [The final quote] => 22,158.00 ) ) [curtain_price_total] => 686 [curtain_value] => Array ( [Curtain Type] => Handmade triple pleat buckram heading [Track or pole width] => 5000 [Finished length of the curtain (drop)] => 5000 [Type of lining] => Blackout [Fullness] => Normal (double fullness) [Interlined] => No [Fabric width] => 139 [The final quote] => 22,158.00 ) [curtain_title] => 2 [cur_v] => 22,158.00 [cur_t] => The final quote It seemed to me at first glance to be a number formatting issue however the value of 'curtain_price_total' variable is already incorrect so the formatting seems to me to be irrelevant. It's a mystery to me and any help would be greatly appreciated. Cheers Paul
  5. No problem Larry. However, if you don't use localhost to test your email coding what do you use? My 'plan B' was to upload the code to a stand-alone page on my own live site and test it there. Obviously a bit more of a phaff because there's more chance of me winning a Nobel prize for PHP coding than my code working first time which means going backwards and forwards with FTPs. Cheers Paul
  6. Hi all, I've written the following very simple piece of code. <?php echo' <h1>Your emails</h1> '; $to = 'demoPHP@localhost.com'; $subject = 'Email testing'; $message = 'test'; mail($to, $subject, $message); ?> The email doesn't arrive in Thunderbird using Mercury Mail in XAMPP on Windows. The text 'Your emails' appears in the browser so I know the file is being processed by PHP. I can send an email using Thunderbird from 'demoPHP@localhost.com' to 'demoPHP@localhost.com' and it arrives in the inbox OK, so I know that Mercury is configured OK in that it's sending emails. I've changed the php.ini file to the following: [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = postmaster@localhost.com Does anyone have any ideas what I'm doing wrong. I'm actually running a Windows 64bit system. Would that make any difference? I'm referring to the fact that the php.ini file refers to 'Win32'. Thanks Paul
  7. Hi again, Ignore this post, I've worked it out. I was looking for redirects but what I've just noticed is that I've left some form action code on one of the include files that should have been deleted. Delete it and it works OK. Learnt something today. My apologies for bothering everyone. Cheers Paul
  8. Hi everyone, Hope you're all well. Have a look at the following seemingly very straightforward code from a file called 'orders/customer_details.php'. <form action="customer_details.php" method="post" /> <input type="hidden" value="TRUE" name="submitted" /> <input type="submit" value="Place your order" /> </form> Unless I've been misunderstanding for years when I click on 'Place your order' the page should direct to 'customer_details.php' (itself) where there will eventually be other form fields, validation etc. However it redirects to 'orders/basket.php'. I have no idea why? I've looked through every line of code in 'customer_details.php' and the only time the word basket is mentioned is in comments or HTML. There is no redirection code to 'basket.php'. There is file called 'basket/basket.php' but it's in a seperate directory to this redirection which is to orders/basket.php. I've tried everything I can think off. I've deleted the file and typed everything in manually. I've copied the code through Notepad in case there's anything odd in the bckground. I've bypassed Dreamweaver (because sometimes that has a mind of its own) and ran the url manually through XAMPP. Nothing seems to work. I can't believe something so easy doesn't work. I've loads of other forms on this site with exactly the same code and they work. Bizarre. Any help would be greatly appreciated before I go crackers! Cheers Paul
  9. Thanks for the advice. I'll give that a go tomorrow. One thing I find frustrating as a part-timer at this is how often I spend hours, if not days on a script and get 3/4 way through it and find it won't work because I've got the logic wrong. Do you do an outline like you have above before you start a script or or from experience can you just go from top to bottom? Paul
  10. No, sorry. Just reread my post. That's what it sounds like but no. Paul
  11. Hiya, The hidden field is there. My confusion is that if there was a problem with the DB query then $row would not contain 25.00. If there was a problem with the form element then the $_POST array would not contain H_H_allowance. One just doesn't seem to pick up the other. I've even just checked my spelling of allowance....make sure I didn't put allowence anywhere. Spelling is not my strong point, nor is PHP it appears! One of those days today. Cheers Paul
  12. Hiya, Really! I've tried that before and got myself in a right mess. If you had form 1 then if {isset($_POST['submitted'] etc. would apply to form 1. Then presumably you would validate that, assign it to variables and then load form 2 based on the answers in form 1. However how would you ensure that form 1 never reloaded? Would you need to nest forms within an if / else? I've always used the same approach. Code at the top with an {isset($_POST['submitted'] and the single form below. I must be getting old because it's never ossurred to me that more than one form can be on the same page. Is my thinking going in the right direction (the nesting within an if/else, not whether I'm getting old. I know that!)? Cheers Paul
  13. Hi all, As the topic title suggests I'm trying to populate a hidden form element with a number retrieved from a DB query. The hidden field appears in the post array but with no value. Yet the value appears in the debugging info. This is the query (it only returns one row): $q = "SELECT H_H_allowance FROM curtain_constants"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_num_rows($r) == 0) { //If there's nothing in the DB display this message echo '<p>Oops, something\'s gone wrong. We\'re working on it, please would you try again later. Apologies.</p>'; } else { $row = mysqli_fetch_array($r, MYSQLI_ASSOC); } This is the hidden form field: <input name="H_H_allowance" type="hidden" value="<?php $row['H_H_allowance'] ?>" /> This is the relevant debugging info: [_POST] => Array ( [fabric_width] => 139 [track_pole] => [drop] => [fullness] => 2 [vert_pattern_repeat] => 0 [hor_pattern_repeat] => 0 [pattern_match] => no [H_H_allowance] => [submitted_curtains] => TRUE [submit] => Get fabric quantity ) [row] => Array ( [H_H_allowance] => 25.00 ) Thanks once again. Paul
  14. Hiya HartleySan, Thanks for the response. I'll use sessions I think. The reason I'm using multiple pages is that some fields are only going to be displayed depending on the answers to previous questions. Yes, this can be done in JS but I'm creating a non-JS version first. Cheers Paul
×