Jump to content
Larry Ullman's Book Forums

hacker

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by hacker

  1. Larry,

     

    In the beginning of your book, you mentioned using the Twitter Framework instead of a third party template (I read Ed.2 quite some time ago) to create the user interface and in my nebulous way, I was asking whether WordPress can be substituted.

     

    That said, you now realize I know less about the Twitter Bootstrap framework than I do about WordPress. :^)

     

    Thanks for your help,

    Don 

  2. Larry,

     

    Thank you for the reply.

     

    I am pressed for time so I suppose having a look around the web for an appropriate e-commerce plugin wouldn't hurt. However, since I am not shipping tangible goods, I do not have the need for a traditional e-commerce package.

     

    I was thinking, since at least one WP plugin I installed (IIRC, BuddyPress) added tables to the database I originally set up for WP, I could incorporate additional tables for storing customer account information (less CC numbers) and the data necessary for transmission to a payment gateway (rather than PayPal).

     

    Thanks again,

    Don

     

    P.S. Is a 3rd edition of Effortless E-Commerce in the stars, so to speak?

  3. I just purchased your book and have almost made it to the end of chapter two.

     

    Perhaps my biggest concern at this point is, I want to integrate the techniques I learn in "Effortless E-Commerce 2nd Ed" into WordPress themes (at least initially). Am I barking up the wrong tree? I know there's e-commerce plugins out there that can be integrated with WP, but I want to learn e-commerce at the code level.

     

    Thanks for your input... I've got a shelf full of your PHP books but I'm not yet at the developer level with respect to WordPress.

     

    hacker

  4. Thank you Larry.

     

    I've got another question that came up a bit later in Chapter 10, if you would be so kind...

     

    I placed http://www.apple.com/ in my array of URLs to validate (script 10.2 - check_url.php) and it came up 400 Bad Request even though the link works fine.  The http://www.apple.com/ link was flanked by URLs that came up 200 OK in my $urls array.  Can you explain why this might happen?

     

    Thanks again,

    Hacker

  5. Larry,

     

    There's a couple points on page 330 I'd like to discuss.

     

    Can you expound on:

     

    "... unless you are merely copying the entire contents of a file, you'll need to develop some system for gleaning the parts of a page you want according to how the data is structured." Are there references that go into detail regarding this?

     

    Also...

     

    Without the aide of gummy-stuff.org (pulled from the web), what resources do we have for format string information? I've noticed the references made in your tips section on page 332; however, do those "networking-related" classes of PEAR supply format strings necessary to communicate with Amazon, Yahoo, etc.?

     

    Thanks,

    Hacker 

  6. That sounds like a reasonable approach to me. Thanks for the question!

     

    I found this to work much better...

     

    By placing the following line of code in page.php:

     

    $_SESSION['page'] = $page; after if ($page) {... (line 25 in your book)

     

    AND...

     

    $page = (isset($_SESSION['page'])) ? $_SESSION['page'] : null;

     

    after session_start() in utilities.inc, all the gremlins were run out of town.

     

    Hacker

  7. The page always expects the id to be passed in the URL. You can either change the form's action to do that, or you can change the code so that it can accept the ID in GET or POST. If you do the latter, you'd store the ID in a hidden form input.

     

    Hi Larry,

     

    I hope it's OK with you if I resurrect this old thread.

     

    Anyway, could edit_page.php first check (just after utilities.inc.php is required) whether the REQUEST_METHOD is set to GET or POST? If it is set to GET the value of $_GET['id'] is saved in $_SESSION['id'], (or pehaps something like  $_SESSION['pageID']) then one can use the $_SESSION variable when submitting changes to the $page object.  This logic seems to work OK (at least so far); however, I don't know if it's fundamentally sound in terms of security or OOP principles.

     

    Thanks,

    Hacker

  8. It's still wrong according to syntax...

     

    What's still wrong according to syntax? Are you refering to my $dog->getCount() in my opening post? What part of "...A property declared as static can not be accessed with an instantiated class object (though a static method can)" don't you understand? If you're not satisfied with the PHP manual, I don't know what to tell ya.

     

    Actually, I don't give a hoot... the PHP manual cleared up my confusion and I'm happy.

     

    Good night,

    Hacker

  9. Larry,

     

    I was nosing around in the PHP manual and suggest you read this:

     

    http://us3.php.net/manual/en/language.oop5.static.php

     

    Near the top of the page it says:

     

    "Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static can not be accessed with an instantiated class object (though a static method can)."

     

    Regards,

    Hacker

  10. The error is obviously related to error reporting settings.

     

    OK, so what else do I need to do in my php.ini file in order to see some warning action?  I realize this issue isn't directly related to Larry's book so if you want to refer me to another source, go right ahead.

     

    I'm running PHP version 5.4.24 and Apache 2.2.26 on MacOSX (v10.9).

     

    Hacker

     

    P.S. BTW and with all due respect, while you keep beating the error reporting drum, that doesn't really reconcile the fact that Larry wrote in his book, "static methods are almost always public because they can't be called through an object."  Granted, I'm no Zend Certified engineer but when someone says they can't be called through an object, I expect to see the script terminate with fatal errors.

     

    Is Larry on vacation?

  11. Yes? Change that to -1 and you'll get the error I wrote about.

     

    Antonio,

     

    Got any other ideas?  My error_reporting is now set to -1 (according to phpinfo) and I'm still getting the following output (while getCount is declared public static) without error messages or warnings:

     

    After creating a dog, I now have 1 pets.

    After creating a dog, I now have 1 pets.

    After creating a dog, I now have 1 pets.

    After creating a cat, I now have 2 pets.

    After creating a ferret, I now have 3 pets.

     

    While using the following code:

     

    $dog = new Dog('Old Yeller');

    echo '<p>After creating a dog, I now have '.$dog->getCount().' pets.</p>';

    echo '<p>After creating a dog, I now have '.Pet::getCount().' pets.</p>';

    echo '<p>After creating a dog, I now have '.Dog::getCount().' pets.</p>';

        

    $cat = new Cat('Bucky');

    echo '<p>After creating a cat, I now have '.Pet::getCount().' pets.</p>';

     

    $ferret = new Ferret('Fungo');

    echo '<p>After creating a ferret, I now have '.Pet::getCount().' pets.</p>'; 

     

    I'm toward the end of chapter six now and trying to make my way into the example contained in chapter nine. If I don't make it back here for a while... thank you in advance.

     

    Hacker 

  12.  

    This is due to error reporting settings. You'll get an E_NOTICE warining you about "Strict standards" and calling a static method in an object context.

     

    I'm just going to respond to your first comment for now and I'll study your example when I have more time; however, I think I found the answer to my second question in the "Access Control" section starting on page 165... thank you.

     

    Now back to the first point... I get no warning of any kind... at least while running PHP 5.4 (yes, I have display_errors turned ON).  Like I said above, I get the same output whether I use $dog->getCount() or Pet::getCount().

     

    Dog::getCount() also works, but that's no surprise to me.

     

    Thanks,

    Hacker

  13. Larry,

     

    At the end of chapter 5 you mention in a tip that static methods are almost always public because they can't be called through an object.

     

    Substituting $dog->getCount() for Pet::getCount() in line 74 of script 5.6 (page 179) produces identical output. Can you please expound?

     

    Also... Dog::getCount() prints the same results as Pet::getCount() when getCount() is declared public static; however, Dog::getCount() does not print properly when it is declared protected static even though class Dog extends Pet{ }?

     

    Can you please explain that as well?

     

    Thank you,

    Hacker

  14. BTW Larry,

     

    How would one output the parent_id to the HTML list so one can easily reference the parents to their subtasks directly in the <li>?

     

    Thank you,

    Hacker

     

    Here's what I have so far:

     

    function make_list($parent, $x=NULL) {
        static $tasks;

        if (is_array($x)) {
            $tasks = $x;
        } else {
            $parent_id = $x;
        }

        
        echo "<ol>\n"; // Start the ordered list
        foreach ($parent as $task_id => $task) {
            if ($parent_id > 0) {
                echo <<<EOT
    <li><input type="checkbox" name="tasks[$task_id]" value="done"> Task Id $task_id: $task <span style="color:red;">(of parent task id $parent_id)</span>
    EOT;
            } else {
                echo <<<EOT
    <li><input type="checkbox" name="tasks[$task_id]" value="done"> Task Id $task_id: $task <span style="color:red;">(no parent task)</span>
    EOT;
            }

            # Check to see if the last task printed is a parent task:
            if (isset($tasks[$task_id])) {
                make_list($tasks[$task_id], $task_id);
            
            echo "</li>\n"; // Complete the list item.
            
        } // End of foreach loop.    
        echo "</ol>\n"; // Close the ordered list.
    } //------------------------------------------------------------>end make_list()

  15. In chapter one, make_list() evolves into a function that declares $tasks as a static variable so the function can remember the $tasks array between function calls.

     

    I modified make_list() in the following way and it appears to work fine, at least for a three deep nested list:

     

    function make_list($parent, $tasks) {
        echo "<ol>\n";
        foreach ($parent as $task_id => $task) {
            echo <<<EOT
            <li><input type="checkbox" name="tasks[$task_id]" value="done"> $task
    EOT;
            # Check for subtasks:
            if (isset($tasks[$task_id])) {
                make_list($tasks[$task_id], $tasks);
            }

            echo "</li>\n"; // Complete the list item.
            
        } // End the foreach loop.    
        echo "</ol>\n"; // Close the ordered list.
        
    } //------------------------------------------------------------>end make_list()

     

    The first function call remains the same; i.e., if (!empty($tasks)) make_list($tasks[0], $tasks);

     

    Logically, am I missing something here? I've only tested it so far with PHP 5.2.

     

    Thank you,

    Hacker

  16. Larry,

     

    In the RewriteRule for browse.php on page 176 we have (discrepancy indicated in red):

     

    RewriteRule ^browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3

     

    and on page 177 we have:

     

    RewriteRule ^browse/([A-Za-z\+]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3

     

    Which line of code is correct and why are we including the hyphen(s) indicated in red in the first place?

     

    Thank you,

    Hacker

×
×
  • Create New...