Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by maxxd

  1. Now, combine the advice you've gotten here with the advice you've gotten at your phpbuilder thread and I should think you'll be able to figure it out quite quickly.
  2. You've got single quotes around $semail in your setAddress() call. PHP doesn't parse variables inside single quotes - remove them. And Barand beat me to it...
  3. This is too vague to answer, I think - is the 'undefined' something you wrote in your code? Are you using third party libraries? Post your form and processing code and we'll take a look. My initial thought is that you're doing something like if(isset($_POST['submit'])){ // process the form }else{ echo 'undefined'; } (assuming the submit button is named 'submit') which won't work with Internet Explorer. But that's only my initial thought because it's something that has bitten a lot of developers.
  4. That just made me shoot milk out my nose and I haven't had milk in years. NotionCommotion - yes, just like that. Unless you have a reason to hide the sub-objects interface or you need to do some manipulation before or after interacting with the sub-object, in which case write the pass-through method.
  5. As far as I view it, scope is scope whether it related to methods or properties. Of course, that's easy for me to say because I believe most things should be privately scoped anyway - at least initially. More on that later... The Open/Closed principle (quoting Wikipedia here) states that "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification". Using private (and to a degree protected) methods and properties - the way I understand it, anyway - is the basic building block of the principle. By using public getters and setters, you've created an effective and reliable API that other differently typed objects and classes can use with confidence. So you've got the extension aspect covered with the public API, but by encapsulating the inner guts of the class with private scope, it's tightly closed to modification except where monitored and expected. Personally I thinks it's better to start off with a tighter scope (private), then loosen up on methods as necessary to create your API. As ignace points out in the other thread (this post) if you find you need to give privileged information to a child object, set that information's scope to protected. All that having been said, I am a bit more strident in my belief that properties should be private no matter what. Methods need to be public at times - properties don't. By using a setter method you can validate and control the value before you assign it to a local property, and using a getter method allows you to tailor the response. And yes, it is sometimes a pain to write pass-through methods to sub-objects, but I feel the trade-off in system security and consistency is worth the time. Hopefully this all makes some sort of sense - I'm trying to quit smoking this week and my brain's having trouble keeping up.
  6. Print out records 21 & 77, as well as the value of $first_name. My gut's saying that you're not using the values you think you're using, either in the processing script or the database. Of course, without seeing your full code and data set, it's difficult to know for sure.
  7. Isn't this basically the same question we talked about here? I do realize there's a slight difference, but unless I'm missing something that difference seems extremely small.
  8. @Zane - I'm at the beach in Wilmington. It's rough... 😁
  9. Thanks very much, all - first round's on me, absolutely! 😁
  10. And stop using mysql_* functions. They've been deprecated long enough that commercial hosts are starting to catch up. I'd bet you've got maybe six months to a year before any work you do to make your code work is rendered useless anyway.
  11. IMO, a series of serialization objects is a good example of when using inheritance and protected properties is justified. Have a base serialization factory class that then calls child classes for JSON serialization, normal serialization, XML output, MLS XML, MathML, SuperSpecialUnicorn serialization (I'm making up examples, obviously), whatever. Each of the child classes can then read and modify any protected property on the parent factory class and as long as you program to that parent factory's API you really don't have to care which it is.
  12. Take this in the spirit it's offered, but this code is a mess and really shouldn't be used on a production server. Especially if it's dealing with loan applications and tracking. You're wide open to SQL injection, none of the output is escaped, the queries are inefficient, and the mixing of logic and display is going to continue to make maintenance a nightmare. As to your question, given the fact that you want it to calculate when you select an option, this is a JavaScript question, not a PHP question. You'll need to check the value of the loan amount (which I assume is #original) within the loanamount() function to know which set of values to apply. Read what you wrote to describe the intended behavior - that's great pseudo-code. Now, using a simple if...else construct you should be able to convert that pseudo-code almost exactly as described to functional JavaScript. Give it a go and post what you come up with here.
  13. I'm with ignace on this one - object properties should be private until they absolutely must be made public (which is hopefully never). Protected is better than public, but most patterns these days prefer composition over inheritance so protected is kinda pointless. Having said that, I'm a big fan of the encapsulation aspect of OO so I may be a bit biased. I think Google at one point released a white paper on writing speedier code and one of the things they recommended was eschewing getters and setters in favor of public properties. No, but thankyouverymuch.
  14. Throwing in my $.02 - as far as thorough, understandable explanation of OOP as it specifically relates to PHP I've found this book to be a great resource - https://www.amazon.com/Objects-Patterns-Practice-MATT-ZANDSTRA/dp/1484219953/ref=sr_1_1?ie=UTF8&qid=1526221870&sr=8-1&keywords=php+objects+patterns+and+practice. Some of the earlier chapters may be a bit basic for you given where you stand and the research you've done, but I've actually bought the second, third, and fourth editions (the fifth isn't out in B&N e-book format yet, as far as I can tell) and to this day just pick it up to read on a random basis. I know this doesn't specifically address any of the questions you've laid out above, but if you're looking for an enjoyable read that's also informative, it's worth taking a look.
  15. Ahh. I've not used BuddyPress before, so I'm afraid I'm not going to be of any help on this... Good luck, though!
  16. If I'm reading this correctly, you're looking for user avatars, correct? If so, have a look here: https://developer.wordpress.org/reference/functions/get_avatar_data/ https://developer.wordpress.org/reference/functions/get_avatar_url/ https://codex.wordpress.org/Plugin_API/Filter_Reference/get_avatar On to some of your other points, there are a lot of files involved in a WordPress theme or plugin beyond just the required functions.php and style.css. If the CSS is being compiled on the fly, then I'd have to bet you're using a page builder. There's nothing wrong with that, they're just not my favorite method of theme development in WP for almost this exact reason - they mangle everything in the database with the shortcodes that most use to actually achieve the functionality. That being said, if the avatars are custom or from a plugin, chances are good that those image's locations are stored in the database. If they're default WordPress, they're served from Gravatar and accessible using the user's email address.
  17. I'd recommend a separate table, just to future-proof the system. If you add 2 more columns to your clients table that track company name and designation, what happens when you decide to track phone number, and address, as well as display a logo for the company? Create a second table with the company-specific data points you need and JOIN the two during your queries when and where necessary. This will also cut down on the amount of work the server has to do if, for instance, you want to display only company listings.
  18. I believe that using animate() to scroll the page down still fires the scroll() event in the browser. If I'm correct about that, you're basically calling the function in an almost infinite loop until the page scrolls to the value of distance - which would freeze your page.
  19. I may be missing something here, but it looks like you're trying to draw in the canvas on the currently loaded page from the remote AJAX target script? It looks to me like all you're doing in the onreadystatechange() handler is updating the contents of the #graph_field div, which isn't a canvas element to begin with. You'll need to apply the data returned from the AJAX call to the canvas on the currently loaded page. Whether that's - as Barand suggests - an html string that you replace the entire canvas contents with or a dataset you manipulate in JS to draw into the element, the modifications have to be made on the currently loaded page. Basically, you're not loading the canvas element after the AJAX payload has been received (although you could, of course, dynamically create a new canvas element which you then append to the currently loaded page) you're manipulating the canvas element that's already there. That manipulation can happen at any time.
  20. Barand's right about the quotes - looks like you're missing a closing quote from your HTML block. This is also a good reason not to output HTML via php - use a template language like Twig and this wouldn't be a problem (or at least would be easier to identify as there wouldn't be that huge chunk of HTML output in the middle of your script). Not only that, it would add the escaping your current script doesn't do. As a side note just in case the formatting isn't a copy/paste issue - proper and consistent indentation makes scripts a lot easier to debug.
  21. When was the code you downloaded written? It's using old-style class constructors that are deprecated in 7.0 (if you scroll down a bit you'll see the warning about the deprecation). Also, the second declaration of query() isn't using mysqli_query() correctly - the connection and query are passing in the wrong order. Finally, I could be missing something here but the mysqli_exec_batch() method looks really very dangerous...
  22. Use the register_post_type() function for any and all post types you're creating. Make sure 'show_in_rest' is set to true in the arguments to make the data available via the WP rest api.
  23. maxxd

    PHP Mapping

    Have you tried HighMaps? Not used it personally, but I have used HighCharts before and found it easy to use and deal with, and this is by the same people. It's not a strict PHP solution, of course, but it may do what you need.
  24. From the source code, it looks like the first passed parameter is the message and the second is an array of user-submitted form data. You should be able to check the second parameter for the status of your yes/no question, then update and return the message at that point. BTW - you'll find the filter definition in the includes/Actions/Email.php file.
  25. Try require_once(dirname(__FILE__).'/phpseclib/Crypt/RSA.php); Untested and I'm in a bit of a rush to get gone, but it should work for you.
  • 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.