Jump to content

maxxd

Gurus
  • Content Count

    919
  • Joined

  • Last visited

  • Days Won

    24

Everything posted by maxxd

  1. maxxd

    Pull data to page based on id

    Prepared statements in WordPress are sprintf() statements. @SkyRanger - what exactly does the acikudos_table_name() method return? If it's the name of the table, wouldn't you just use that directly as I assume you know the name of the table you've created. If the database table prefix is dynamic you could always use "{$wpdb->prefix}table_name". Also, is there a reason not to create the kudos as a custom post type? It seems like it would alleviate a lot of the problems you're running into (you'd be selecting directly from $wpdb->posts, for instance), however as I don't know the business logic I don't want to suggest you burn a bunch of time on something that won't work for you anyway.
  2. maxxd

    Pull data to page based on id

    I hope my post didn't come across too negative or ... jerky. There are so many ways that things can be done poorly in WordPress it's sometimes hard not to do things wrong. As you keep working with the code, post it here and ask any questions you may have. Let us know what plugin you're dealing with - somebody here may have personal experience with it or the time to do some digging into it, thereby offering better or more specific advice.
  3. maxxd

    Pull data to page based on id

    Barand is right about the equality condition. $wpdb->get_results() returns an array, object, or null, so comparing any of those to an integer (or whatever is passed through $_GET['viewkudoid']) will fail. Beyond that, you're ... I'm sorry, but you're doing it wrong. If you're not going to use get_posts() or one of the internally-escaped functions to get the data you're looking for, at least use $wpdb->prepare() so you get something that might look like a prepared statement if you squint at it long and hard enough. Beyond that, if the plugin you're using has a function to return the database table name, there's a decent possibility there's a function to directly retrieve records safely through the plugin's API. Use that instead of directly injecting a $_GET variable into an unsanitized query string. Other than that, WordPress offers the query_vars and rewrite_rules_array hooks to handle routing, instead of using the kludgy '?{var}={val}' $_GET pattern; admittedly I'll cut a good amount of slack here as that is rather advanced and can be a bit touchy in it's own right. However, one thing that I kinda can't cut slack on is that if you're creating a shortcode, use shortcode_atts() - $_GET may not be set at all, and even if it is it shouldn't matter to the shortcode. Shortcode gets parsed inside the user content, regardless of the page the user is on.
  4. maxxd

    Laravel vs raw php code

    Also, you don't need to use a framework to use a templating language. Twig works just fine as an external library included into and called from a bespoke PHP solution.
  5. Good job - you've figured out the syntax issues with your query (I really do mean that sincerely). Now, before anything else, please look into prepared statements as you're using $_GET variables directly in a MySQL query. Then please google the performance pitfalls of running a 'SELECT * ...' query. As for the coach name, the PHP array from a MySQL query has no idea what table each index of each row in the resultset came from, so the MySQL aliases you set up don't help the PHP output. In other words, the array indexes 'c.coachFirst' and 'c.coachLast' don't exist. The array indexes 'coachtFirst' and 'coachLast' should exist, however.
  6. maxxd

    Multiple Option HTML insert into MySQL

    There are many issues with the code you've posted, but I think it'd be best to start by reconsidering your database structure. Learn about normalization. Once you've got a usable database structure, you can decide if you want to use mysqli (probably not) or PDO (probably), and then learn about prepared statements.
  7. maxxd

    PHP in multiple new windows

    Not gonna lie, I didn't realize attaching a target attribute to a form would do anything at all... There's obviously nothing wrong with your response kicken, but personally (just for readability if nothing else) I'd still seriously consider doing this via AJAX and opening the modal after the processing script returns the data, using a data-{whatever} attribute on the buttons to tell the processing script which logic branch to follow. I have, however, been accused of working harder than I work smart sometimes.
  8. maxxd

    PHP in multiple new windows

    I could well be wrong (as I said I'd just do it via AJAX and open the popup on data return), but I'm not sure you're actually doing what you think you're doing. Check the documentation: https://developer.mozilla.org/en-US/docs/Web/API/Window/open The first parameter to the window.open() call is URL - you're passing 'about:blank' as the URL and sending your form to process.php. Two different addresses, two different actions.
  9. maxxd

    PHP in multiple new windows

    I'd do the data gathering via AJAX, then open the modal window using JavaScript once the AJAX response payload has been delivered. Right now you're sending the form data to process.php while trying to pop open a new window with no actual data attached.
  10. maxxd

    bootstrap form cannot delete placeholder

    This looks like your browser is set to remember form fields. You don't have a placeholder attribute set on the username field, and password fields don't support placeholder attributes (I think - I'm pretty sure that's true...) so the presence of text in that field is a sign that the culprit isn't what you think it. Delete the form data via your preferences.
  11. maxxd

    Help with search function

    What you're looking for is not the way WordPress search works by default. It does a straight string comparison - if the word(s) you typed in the search field are in the title or content of the post (or post type), WP will going to return that post record. Search for an Elastic Search plugin in the plugin directory - I'm pretty sure there are a couple out there.
  12. maxxd

    Site Won't Submit Multiple Variables

    Also hint: In the long run, using either checkboxes or a multi-select combobox will make your life much easier when dealing with this.
  13. What's in this field? It could just be my own personal naming style but this kinda seems like it would hold the referrer value, which sounds like what you want. So, you may have all the information you need already. Otherwise, do as ginerjm suggests and create an additional hidden field with the value you need.
  14. maxxd

    php coding to send email from html form

    Honestly, just formatting your code properly is going to help. You've got single-line comments that are (right now) commenting out functionality due to everything being on one line. Put the comments on separate lines or remove them entirely. We'll be able to figure out what your script is doing, I promise.
  15. maxxd

    php coding to send email from html form

    OK. Now we can safely say the issue is not just in what was originally posted. Format the source code, then post it here again please. It's still unreadable.
  16. maxxd

    php coding to send email from html form

    gw1500se means in your original post here, not the code itself. Notice the button that looks like '<>' in the editor toolbar - that formats code. The code you posted isn't readable on this forum so please edit it and use the code format.
  17. maxxd

    <?php echo "\n" sourcing

    I don't know what theme or plugin you're using, but there are a couple potential issues with how you're going about things. First, modifying the theme or plugin files directly is not recommended because every time the plugin or theme is updated, your changes will be overwritten. Usually in this type of situation, you'd check the files and documentation for action or filter hooks and use those to make your updates from your functions.php file. Working this way will allow those changes to remain after the plugin or theme updates because the actual theme or plugin files haven't been changed. Another things is - given the name of the static method called (frontSections()) I assume this is calling your installed theme's functions that load the head and/or header templates into the page. These are crucial to the functioning of your site as it creates the top half of the HTML page - I think this is probably why you're seeing the WSOD when you remove this call. So, you know, don't do that. Let us know what you're looking at and what about that you're trying to change, and I'm sure with the brains on this board you'll find the help you need to do what you want and do it correctly.
  18. maxxd

    PHP and querystring problem

    Do you have control over the building of the link? Because there should be an ampersand before the 'from' variable (not the question mark), and the value of from should be url-encoded. I'm pretty sure this would take care of your issue. If you don't have control then honestly I'm not sure exactly how you'd fix the issue - maybe parse_url()? Not entirely sure what it does with slightly malformed URLs such as yours, but there's a possibility you can use this and ginerjm's explode() suggestion to figure it out, I guess.
  19. maxxd

    JSON naming convention

    I know - I can't stand snake case, but if it's an array key or database *anything*, my fingers just type it that way. Database tables and columns actually make sense to me because I have a tendency to prepend table names with "tbl_". In case I get confused, I guess. But "tbl_student" or "tbl_orders" reads easier to me than "tblStudents" and "tblOrders". And once you've got that established for table names, you might as well keep it going for the column names because then you don't have to think too much or type different patterns in the middle of custom MySQL statements. It makes perfect sense. Really. The array key thing I can't even pretend to explain, it's just something I realized I was doing at some point. I may have been dropped on my head as a child.
  20. maxxd

    JSON naming convention

    I align almost exactly with @kicken except I use snake case for database, table, and column names, and - for whatever random reason - array keys. Couldn't explain the array key preference if I absolutely had to as I really do hate snake case. Unfortunately, I currently work with WordPress so I have see that crap daily...
  21. maxxd

    Unexpected end of JSON input

    Yeah, Jason Larke's answer is pretty much exactly what taquitosensei and I have been saying. No. The 'public statements' before the __construct() method are called object properties or object variables. The reason I'm passing in 4 random values is because the constructor signature calls for 4 parameters to be passed in; you've got The first 0 is now assigned to $role, the second is $tag, third is $location, and fourth is $job_id. They're not used in the class you've written, so I passed in nonsense values. There's a bunch of different reasons for having multiple files. The biggest is that AJAX is a client-side technology, but database interaction is a server-side technology. So you need to have the JavaScript file and a PHP file. The JavaScript is separate from the HTML file because if it was all in the same file you'd run a decent chance of breaking the functionality every time you change a DOM element. The PHP is the server-side file that actually gathers the data and prints it back to the AJAX call. Adding the lines above to the jobsDatabase.php file will automatically create an instance of the jobsDatabase class and run the getAllRoles() method of that object, which in turn prints the gathered data. Basically, you're dealing with a whole lot of moving parts with what you're trying to do. Given what we've talked about, I'll recommend again just stubbing in the data - instead of trying to use an additional PHP file to connect to the database and gather the actual data, just make up an array and print it to the AJAX call. In the AJAX success() callback, print that data to screen or console. Once you see the data you're expecting, move on to the next stage - in this case, populating the returned data in the form. From there, worry about actual database interaction. Hopefully at least some of that makes sense - again, it's been a bit of a Monday here.
  22. maxxd

    Unexpected end of JSON input

    If that's all the code there is and you're not using a framework, then yes, you need to call the method on the object. Add this to the bottom of your file: $job_data = new jobsDatabase(0,0,0,0); $data = $job_data->getAllRoles(); die($data); Note that anything happening here is dependent on the contents of connect_database.php. While you're learning it may be a little easier to create a static array inside getAllRoles() and output that. That way you know everything is self-contained and you know what you're expecting. This should make it easier to track down any issues and errors in the process.
  23. maxxd

    Unexpected end of JSON input

    Did you write jobsDatabase.php yourself? Are you using a framework or library?
  24. maxxd

    Unexpected end of JSON input

    Right, and we need to see what the actual JSON string is. If you're using Chrome, select 'More Tools > Developer Tools' from the menu (option - command - uppercase 'i' on a mac, Ctrl + Shift + uppercase 'i' on Windows). You'll see the 'Network' tab along the top - select that, then trigger your ajax call. You'll see 'jobsDatabase.php' under the 'Name' column. Click it, then select the 'Response' tab from the details screen that appears. This will show you the raw JSON output, which may have a slightly more helpful error message.
  25. maxxd

    Unexpected end of JSON input

    I just took a look at the code again. I missed the 'method' in your data set - so, yes it's possible that is all being handled behind the scenes and not something you need to worry about. (Sorry - it's Monday in a big way here...) So that begs the question, what does the response show in your browser's devtool's network tab?
×

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.