Jump to content
Larry Ullman's Book Forums

chris14

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by chris14

  1. If the error is "Please enter your zip code" then it must be being set in the following code section: >> //Validate the zip code: >> if(preg_match('/^(\d{5}$)|(^\d{5}-\d{4})$/',$_POST['zip'])){ >> $z=$_POST['zip']; >> }else{ >> $shipping_errors['zip']='Please enter your zip code!'; >> } And in this code section the only test is in the second line, ie: if (preg_match...... Therefore the only place you need to look is that line. And the only thing that can be wrong on that line is that the variable S_POST('zip') does not match the test on the first part of the line. You could add a temporary extra line just before this code section, eg. echo $_POST('zip'); so you can check the variable does contain the value you expect. If it does, then it must not be meeting the regular expression requirement. I find these regular expressions to be very hard to understand. Search the web for some sites that explain with simple examples what each bit means. And if you do need to change the expression (eg. maybe to suit your non-USA style zip codes) you'll almost certainly find an example you can cut and paste.
  2. My Thank you page mirrors Larry's code also. It starts with redirect_invaliduser('reg_user_id'); The redirect_invalid_user function does: if (!isset($_SESSION['reg_user_id'])) { echo "Error -- reg user no set"; (well I just made that up:-) Anyway, SOMETIMES there is no error, but SOMETIMES reg_user_id is not set. (I checked and it is not set in the Thankyou page either).
  3. After a bit of further reading on the internet, it is suggested that session_start() must be the very first thing on the page. In may current code (ie. the config.inc.php ) there are a few lines of code (and lots of remarks which I presume do not matter) before the session_start(). Could this cause such an intermittent problem?? I will do some tests.
  4. When someone pays using PayPal, they return to my Thanks.php page, and SOMETIMES this exits because the $_SESSION[reg_user_id'] is not set. I am using the code from Larry's book. About half the times it all works OK. Before I go to PayPal I make sure that the Session variable is set. Any suggestions as to why it sometimes remains set, and sometimes gets unset? ie. I do not know enough about what could cause this. As far as I can see, I am doing exactly the same thing each time. The rest of the POST variables from PayPal are correctly set, so as a temporary measure I will take out the check for the $_SESSION variable being set.
  5. Thanks Larry I think my hope of a simple set of rules is not possible :-) To your explanation I think we need to add that variables must be enclosed in quotes, unless they are Table names or some such, in which case no quotes??
  6. It looks as if $fid only will be defined if the $_GET['id'] statement is true, so that is where I would start looking. You could add a temporary line such as echo $fid; to check what $fid has been set to, and even set $fid = "1234" (or whatever) to check if the program works when $fid is defined corrrectly. In the errors list I note that the file /views/noproduct.html cannot be found or included. Might be worth checking this file is on the correct location.
  7. I have got all the examples in the book to work, but when I change anything a bit of trial and error is often required. I have just spent a couple of hours searching the internet for a complete set of rules about including PHP variables in a mySQL query -- and failed. But got lots of conflicting advice. And even the few rules I've found (eg. INT variables don't need single quotes but STRINGS do) seem to get broken by Larry -- eg. sometimes you use $uid, sometimes '$uid' ). And I've read that arrays need enclosing in curly braces {}, and some people say you shoud always enclose all variables in these to make things easy and consistent. I note Larry uses them in a few places in the book. In summary, I'm confused. Please can anyone point to a good article or tutorial, or give some tips.
  8. Thanks for the comments. I am in UK using GBP and having tried very hard to use PayPal Sandbox, read all the PayPal Forums and seen that others have the same problem with no solution from PayPal, and having no response from PayPal Help (except automated "we will look into it"), I gave up. I now just use the real PayPal for testing (with some dummy product with a price of 0.05 so it doesn't get too expensive. I might try the Sandbox again, having read the bove. Maybe...
×
×
  • Create New...