Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. KevinM1

    Firefox 6?

    Firefox 6? That's old news. Firefox 8 is already on the nightly: http://www.extremetech.com/internet/89570-firefox-8-is-20-faster-than-firefox-5-matches-chrome-14
  2. He's likely using the Firebug extension for Firefox. It's invaluable when you're trying to figure out why your JS isn't working.
  3. Yeah, a chapter on OOP really won't cut it. It will teach you just enough to get really confused about all of it. For $db, you have two general choices - 1. Hard code it into the object(s) that need to use it. Bad idea, for obvious reasons. 2. Inject it into the object(s) that need to use it. Much better, as you can change database implementations on the fly. This is what you're doing with the constructor.
  4. Wouldn't the solution be to fix the errors rather than squelch them?
  5. To be honest, you'll need to get the fundamentals down first. Do you have Zandstra's book? That should get you well on your way.
  6. First, there's not a lot of point wrapping your Mysqli object within another object. It's already an object, and you're not adding any real functionality to it. Second, objects contain references to other objects all the time. That's where the true power of OOP lies. Composition (objects referencing or containing one another) is generally preferable to inheritance. That's not to say inheritance is bad, it's just that unless you're defining a family of classes, composition is the way to go. What you need to do is create your Mysqli object, then pass it into your User object's constructor, like so: class User { private $db; public function __construct($db) { $this->db = $db; } // rest of class } $db = new mysqli($db_host, $db_user, $db_pass, $db_name); $user = new User($db); // there are better/more advanced ways to do this, but stick with this for now
  7. Try: $sql="INSERT INTO coupons (coupon_code, fname, sname, email, phone) VALUES ('{$_POST['coupon_code']}','{$_POST['fname']}','{$_POST['sname']}','{$_POST['email']}','{$_POST['phone']}')"; You need to wrap array variables in {} if you're trying to interpolate them in a string. Also, you need quotes around their keys (e.g., $_POST['phone']).
  8. I'd just put the link in the middle, where 'Da Rules' already is on the blackboard. I actually tried clicking there when I first visited the site. I still think they should, at the very least, be in HTML format in addition to .pdf. Some other schools may not allow Adobe plugins (if they have smart IT managers, anyway... Adobe products are pretty bad when it comes to security, and represent common attack vectors, with Flash Player and Acrobat Reader being the worst), and I'm not a fan of relying on a non-browser-only solution when it's not necessary. You can make a printer friendly version with just HTML and CSS as well, using CSS' @media directive.
  9. 'Da Rules' are at the bottom of the page, and a .pdf file at that. Why? You can easily replicate them as an HTML page.
  10. In the future, please put all code in either or tags.
  11. Yes, and then screw up his box model and all block elements on the page.... @OP - have you tried running it with Firebug? Have you tried just a simple HTML 5 doctype: <!doctype html> ?
  12. w3schools is bad. See the link in my signature for more info. For PHP, nothing beats the online manual: http://php.net/manual/en/langref.php And the quick function reference: http://www.php.net/quickref.php For HTML, CSS, and JavaScript, use the Mozilla Developer Network: https://developer.mozilla.org/en-US/learn/
  13. The '->' is an OOP operator, specifically the 'to object member' operator. It's used when trying to access an object's public member (either field or method (function)). Frameworks assist in building applications by providing a lot of the basic, underlying structures most/all apps need. For MVC frameworks, they provide the front controller, routing mechanism (including the route table itself), the base class for the controllers, and, a lot of time, a ORM to help with the model as well. It allows the developer to focus on developing an actual site/app rather than the low level (yet still important) structural code.
  14. First of all, stop going to w3schools. The site, in a word, sucks. See the link in my signature for more info regarding that. Second, half a year isn't very much time at all. The people with badges here (including myself) have spent years writing PHP. You seem to be about where you should be. Wanting to improve your skills is admirable. The best way to do it is to write code. You're actually sitting on a gold mine of potential problems to solve right here. When someone asks a question, attempt to solve it. Compare your solution with the others. Try to add to it, or do it in a better way. There's nothing like attempting to solve real world problems. This forum is filled with them.
  15. MVC frameworks fulfill the same niche as other frameworks - to get you up and running doing what you need to do quickly. The time I could spend writing and testing a front controller, route tables, ORM, a bunch of utility classes (form validation, file handling, etc.) is, instead, spent on writing code which will make me money.
  16. No, it's not. Anyway, as to why 'global' is bad.... Functions should be seen as black boxes. Their innards (function definition) should be hidden from view. All that one needs to know about a function in order to properly use it is its signature - its name, explicitly required parameters, and return type (which is kind of glossed over in PHP). 'Global' adds implicitly required parameters to the mix, thereby muddying up the function's signature. Further, it breaks the whole idea of how a function should work, as it creates a link in the function to the environment it will be used in. Rather than being abstract black boxes which can be used in a variety of situations, they're now bound to a certain kind of context. The problem only magnifies as the use of 'global' continues. Code is dependent on other code with no real indication of why. A change in one part of the system would likely necessitate a change in another. This is known as coupling, and is considered very bad. And, if the required 'global' is missing, or not of the proper type, it can be very difficult to find and fix, requiring one to actually dive deep into the code rather than simply look at the function signatures to get a feel for what's going on. Besides, 'global' is completely unnecessary anyway. There's already a mechanism to pass variables into a function - the argument list. Use it, love it, and if you feel you're passing too many parameters into a function, chances are your design could be improved.
  17. More to the point, what does "doesn't work" actually mean?
  18. I think it's okay to leave the left-hand navigation box where it is for the discussion board. It's in a natural place. That said, I think the discussion box itself could be made a bit wider. It suffers from the same smooshed problem as the tutorials. I think I'd also make the navigation box a bit narrower, or smaller overall. I can't seem to find a user page.
  19. Downvoting may be more tricky given our newbie friendly stance. Positive reinforcement only may be the best route to go.
  20. Bill Gates Steve Jobs Mark Zuckerberg Not necessarily famous strictly because of the code they wrote, but there's no denying their worldwide fame and their impact on the industry. That said, why does fame matter?
  21. Maybe a couple of points. We need some way to make the answer post stand out in a thread, Maybe the current topic solved icon somewhere and/or a green border around the answer's text box or something.
  22. AFAIK we're talking about upvotes, like how it is on StackOverflow. How hard would it be to implement both, like with SO? Having the OP of a thread select an answer could automatically trigger the "Topic Solved' mod.
  23. I don't believe you can use the ternary operator in this way. Have you tried simply: if($company['country'] == 'United States') { echo "{$company['city']}, " . state($company['state']); } else { echo "{$company['city']}, " . country($company['country']); }
  24. Are we talking just upvotes? Or being able to select one post as the answer? A combination of the two?
  25. I think it should be consolidated into the user info box. Maybe you could make the actual 'G' in Gloore stand out more. I don't have any particular suggestions, but try playing with it a bit.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.