Jump to content
Larry Ullman's Book Forums

daddytiger

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

1 Neutral

About daddytiger

  • Rank
    Newbie
  1. Solution in earlier post I believe: http://larryullman.com/forums/index.php?/topic/3294-chapter-9-subtotal-not-executing-proper-dollar-amount/?hl=daddytiger&do=findComment&comment=20448 highlights of my 'workaround': Hi all, I had the same problem. It seems 2 problems: Fisrt, qty can get truncated to 127 or 255 in the database. Had to change the type to mediumint(8) to reliably enter semi-reasonable quantities into MYSQL. Couldn't find a mismatch between collation, character sets, it all seemed consistent at UTF8-general, but maybe I missed something there. Had to change to mediumint(8) in the database tables AND stored procedures (qty parameter definition). This first problem affects both the cart and the wishlist, have to fix both places. Second problem, calculating the subtotal fails when in thousands because the number format function returns a string with the comma. try: echo gettype($price); echo '<br>' . 'price is ' . $price; The inherent typecasting to INT apparently is truncating to just the thousands digit. Found this fix online, just insert in cart.php (and wishlist.php) after the get_just_price function but before the subtotal calculation: $price = htmlentities($price); //important part $price = str_replace(array('&#36; ', ','), '', $price); //remove $ and comma
  2. Couldn't find a post I made on this in my "history" here, but it's living on previous pages: http://larryullman.com/forums/index.php?/topic/2862-ex2-coffee-site-customer-phone-number-string-not-integer/ (Same fix from SQL POV), cheers
  3. Note - as it turns out, the last post may not be terribly relevant - if using anet's sample code authorize-credit-card.php, their error code sections implement the same error messaging functionality although with more specificity, confusingly more..
  4. Woops, not done yet correcting billing.php, it works but forgot I had commented out the error section around line 183 or so: else { // Do different things based upon the response: // switch ($response->response_code) { Using authorize. net's "AIM_guide_XML.pdf", forgot where the download link was, but looking at page 67 "Response Reason Codes and Response Reason Text" Table to redo that code section...
  5. Hi Larry et al, I finally got this all working again as nicely as it used to, with much stumbling around. Your results may vary: Authorize.net changed their setup drastically. What worked for me (sure there's other solutions around): Download their latest SDK. (v1.9 as of today) Will NOT work out of the box, need to run Composer to download dependencies. Contrary to their documentation their "convenient" autoloader is not an option, many dependencies, such as serializer, etc will error fatally. In the experimentation and/or after download, the directory structure will be different (e.g., a new subdirectory also called vendor. Especially to the above Zend email problem in email_receipt.php included in final.php: Recall line 64-65 or so: // Uses Composer to autoload the Zend Framework files: require('includes/vendor/autoload.php'); Will now be out of sync? Had to copy the 32 character string part in something like ComposerAutoloaderInit16b7c79bcea786795d7edd9ece25a4bd, from vendor/composer/autoload_real.php to match the line 7 in includes/vendor/autoload.php ( required above from email_receipt.php) ComposerAutoloaderInit16b7c79bcea786795d7edd9ece25a4bd::getLoader(); Basically, I had to also download AND run composer on their sample-code-php-master and use that to follow and replace Larry's excellent comments line by line in billing.php. Also to store full response in database, have to use $full_response = addslashes(serialize($response)); Following their sample code authorize-credit-card.php (prolly want to rename it as an *.inc and remove it's function call), the database call now looked something like: // Record the transaction: $r = mysqli_query($dbc, "CALL add_transaction($order_id, 'auth_only', $order_total, {$tresponse->getResponseCode()}, '$reason_text', {$tresponse->getTransId()}, '$full_response')"); Might have changed some semantics from anet's, e.g, $amount to $order_total, maybe a few more like "description" to "reason", etc.... It CAN work like it used to, just need a coffee or a beer now before tackling the admin capture part....
  6. I had the Authorize.net working beautifully, but it does seem to have stopped working. Getting a Response code |3|, Response Reason Code |49| error: |The transaction amount submitted was greater than the maximum amount allowed. Downloaded the new SDK but it looks confusing... Any magic fixes?
  7. Hi all, I had the same problem. It seems 2 problems: Fisrt, qty can get truncated to 127 or 255 in the database. Had to change the type to mediumint(8) to reliably enter semi-reasonable quantities into MYSQL. Couldn't find a mismatch between collation, character sets, it all seemed consistent at UTF8-general, but maybe I missed something there. Had to change to mediumint(8) in the database tables AND stored procedures (qty parameter definition). This first problem affects both the cart and the wishlist, have to fix both places. Second problem, calculating the subtotal fails when in thousands because the number format function returns a string with the comma. try: echo gettype($price); echo '<br>' . 'price is ' . $price; The inherent typecasting to INT apparently is truncating to just the thousands digit. Found this fix online, just insert in cart.php (and wishlist.php) after the get_just_price function but before the subtotal calculation: $price = htmlentities($price); //important part $price = str_replace(array('&#36; ', ','), '', $price); //remove $ and comma Maybe (probably!) Larry has a better work-around... Still not sure why tinyint(3) doesn't seem to cut cut it...
  8. I just ran into this as well but only when trying to create stored procedures on my remote/hosted. My host (1&1) is using phpmyadmin 2.6.4, really old as is yours. In addition to the MYSQL version above, you'll need a later version of phpmyadmin to support routines. The currrent version is 4.1.5, as of Jan 22, 2014. I'd upgrade, and point to the new phpmyadmin. If you're not using localhost and stuck with the old phpmyadmin on a host, you can upload a newer phpmyadmin to it and point it to your remote database.
  9. Hi Larry and fellow forum users. I am new to stored procedures so... The stored procedures early in the coffee site were returning query results in the php scripts wonderfully, and in the mysql client. But the procedures using the variable "type" (as in coffee or goodies), e.g., select_categories, select_products, etc were returning empty sets in phpmyadmin directly (selecting Routines tab, Execute button). The variable "type" was not being recognized as an IN and so was apparently empty. Fixed using the Routines tab Edit button (filling in the form for the parameter). Must be because the phpmyadmin code is disallowing the variable "type" when a MYSQL attribute for fields is "Type"? (If we change type in the sql creating the procedure to type1 or type_of_stuff, for example, phpmyadmin picks it up as an IN parameter.
  10. Late in chap 10, in testing checkout.php, found that my own phone number was not being entered correctly into the phone field of table customers (database ecommerce2). 1) Pg 190 and in sql file, creating TABLE `customers`: ... `phone` CHAR(10). 2) Pg 289 and in sql file, CREATE PROCEDURE add_customer ... variable p (INT) - should be CHAR(10)? 3) Pg 301 step 16 and in checkout.php (line 134?) after if (empty($shipping_errors)) {: in the query CALL add_customer('$e', '$fn', '$ln', '$a1', '$a2', '$c', '$s', $z, $p, @cid), $p needs quotes like other string fields: i.e., CALL add_customer('$e', '$fn', '$ln', '$a1', '$a2', '$c', '$s', $z, '$p', @cid) Using phpmyadmin. Steps 2 & 3 seemed to fix it.So step 1 is correct, no? Interesting that the zip can be an integer but phone (apparently) needs to be a string. Because we did a str_replace on the phone?
  11. Similar problem with lines 38-44 in ipn.php: // Check for the right values: if ( isset($_POST['payment_status']) && ($_POST['payment_status'] === 'Completed') && ($_POST['receiver_email'] === 'seller_1281297018_biz@mac.com') && ($_POST['mc_gross'] === 10.00) && ($_POST['mc_currency'] === 'USD') .. Had to change to == to make it work, noticed ipn_log.php used 2 equals signs
  12. You're very welcome. Interesting that it should return 1 but it doesn't. Maybe my version (5.4.3) on Wamp/Windows64 or the alignment of the stars.. Feel free to delete and/or repost the following if need be: ERRATA: ipn.php, line 69: $q = "INSERT INTO orders (user_id, transaction_id, payment_status, payment_amount) ... Should be users_id in the query to match the column name in orders table as created in your sql, yes? Will it matter in later chapters which of the two is changed? (I changed the script, not the database, for now).
  13. Working my way through this the 3rd of your books, great great stuff. Got to page 132 - in testing category.php, took your suggestion to test viewing page.php as guest, expired, active and noticed I was always coming up expired, even after changing date_expires field directly in users table in phpmyadmin. I commented out the line (#52?): if ($row['expired'] === 1) $_SESSION['user_not_expired'] = true; and set same to true, and it worked. This seems to fix that line of code: if ($row['expired'] == true) $_SESSION['user_not_expired'] = true; (Same line above wouldn't even work with 3 equals/identity, e.g., === true). Am I wrong??? Thx again for your your great work Larry, you're the man!! daddytiger
×
×
  • Create New...