daddytiger Posted December 25, 2013 Share Posted December 25, 2013 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 Link to comment Share on other sites More sharing options...
Larry Posted December 27, 2013 Share Posted December 27, 2013 Thanks for the nice words! MySQL should be returning the value true as the number 1, which is why I used === 1. However to allow for some flexibility, you could use == true, which also recognizes the fact that PHP treats 1 as being true-ish. Link to comment Share on other sites More sharing options...
daddytiger Posted December 27, 2013 Author Share Posted December 27, 2013 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). Link to comment Share on other sites More sharing options...
daddytiger Posted December 28, 2013 Author Share Posted December 28, 2013 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 Link to comment Share on other sites More sharing options...
Larry Posted December 31, 2013 Share Posted December 31, 2013 Yes, it should be `users_id`. I'll get that corrected. And I'll check this other issue, too. I expect it's the 10.00 that shouldn't be === (because it'll come in as a string, not a number). Thanks for keeping me honest! Link to comment Share on other sites More sharing options...
eonfloyde Posted September 11, 2014 Share Posted September 11, 2014 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 Thank you for your post! This has helped me to understand better what may have happened. I had zero problem logging in, adding pages. However, as you point out I did have an issue when trying to view the pages. I was told that I had to renew (that I had expired). (BTW - this is in relation to login.inc.php line 52 which affects category.php line 35) However, what I did was change the comparison operator form === to == and problem fixed. I am unsure what PHP is returning, and unsure if each version is returning something different. The PHP manual says: $a == $b Equal TRUE if $a is equal to $b after type juggling. $a === $b Identical TRUE if $a is equal to $b, and they are of the same type. Maybe something to do with PHP casting differences in each version? I have no idea, such a newbie here... but I am curios. My guess is one is an INT and the other a String? Retrieved From: http://php.net/manual/en/language.operators.comparison.php Link to comment Share on other sites More sharing options...
Larry Posted September 12, 2014 Share Posted September 12, 2014 Yes, exactly. One is probably a number (of some type) and the other a string. In fact, most text transferred over the internet would be in string format. Link to comment Share on other sites More sharing options...
gmorton01451 Posted October 15, 2014 Share Posted October 15, 2014 The php documentation for mysqli_fetch_array indicates that the return value is, in fact, an array of strings. Therefore if you wish to perform an identity comparison on any of the values (even numbers), you need to enclose the comparison value in quotes. The code will work like this: if ($row['expired'] === '1') $_SESSION['user_not_expired'] = true; Link to comment Share on other sites More sharing options...
Recommended Posts