Jump to content

maxxd

Gurus
  • Content Count

    883
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by maxxd

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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...
  10. 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.
  11. 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.
  12. maxxd

    Unexpected end of JSON input

    Did you write jobsDatabase.php yourself? Are you using a framework or library?
  13. 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.
  14. 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?
  15. maxxd

    Unexpected end of JSON input

    From the jQuery documentation: The AJAX call will connect with the script assigned to the url parameter of settings object. In that script is where some action has to take place. For instance, in WordPress you pass a field named 'action' in your dataset to admin-ajax.php. admin-ajax.php then uses the value of that field to know what PHP functions to call in order to get you the data you need. What taquitosensei and I are suggesting is that you add the following to the end of he script - after the closing bracket of your class definition: $job_data = new jobsDatabasee(); $data = $job_data->getAllRoles(); die($data); and change `echo $json` to `return $json` inside the getAllRoles() method. Before you do that however, what does the response header show in your devtool's network tab after the AJAX call has been made?
  16. maxxd

    Unexpected end of JSON input

    What taquitosensei just posted is what I was talking about. Ajax is connecting to the file jobsDatabase.php and will parse that file. But if there's no action in the script (like instantiating the object and calling the getallRoles() method), nothing will happen.
  17. maxxd

    Unexpected end of JSON input

    Couple questions here, but the big one is this: you are calling the jobsDatabase::getAllRoles() method, right? In your ajax target script (../../../components/jobsDatabase.php) you instantiate a jobsDatabase object, then call getAllRoles() on that object, right? If so, then yes, it might make more sense to return from the method instead of directly outputting (you'd have to dump the returned value from the instantiated object). At this point var_dump() $json after your while loop and check the network tab of your browser's developer's tools to see what the output is. If you're not doing that, then that would be the problem - you're never going to get data from a method you don't call inside and object you don't instantiate.
  18. maxxd

    Woocommerce New Order Table Heading Background Color

    The email files are located in the woocommerce/templates/emails directory - I believe you're looking for the customer-processing-order.php file. Don't change the files in the plugin directory, though, or any changes you make will be overwritten next time the plugin updates. Create a /woocommerce directory in the root of your theme. Inside that, match the directory structure of the plugin's templates directory and copy the file there, then make changes to that version. In other words, copy /plugins/woocommerce/templates/emails/customer-processing-order.php file to /your-theme/woocommerce/emails/customer-processing-order.php. Make the change in the version that's in your theme directory.
  19. Excellent point about unicode and non-printable characters. And while I do agree there should be at least some sort of warning to people that obvious usernames should be avoided, I'd also say the user roles should be relevant to the application, not user names. So 'admin' , 'moderator', etc. are perfectly acceptable user roles and user names because the one has no bearing on the other. That being said, there's nothing at all wrong with dictating which should be used for logging in - and doing so minimizes chances of logic errors during the process.
  20. I have to disagree with @requinix about this - I find limiting the characters in usernames ickier than checking against both the username and email addresses. There should only be one instance of the email and the username in the database - remember, that's one instance each and not a combination of both. So if either exists in the database and the password matches, there's a not insubstantial assurance that it's the correct registered user.
  21. maxxd

    count child nodes in phpsimpledom

    According to the documentation, find() returns null if the requested object isn't found. So check for null before you attempt the children() call - right now you're checking if $lis2 is greater than 0.
  22. maxxd

    Echo Download Link

    @cyberRobot - I had the same thought about the 'download' attribute, but looking it up on MDN it's a legit attribute.
  23. maxxd

    Echo Download Link

    Actually, what you posted and what @micky007 posted aren't quite equivalent. Here's yours: echo " Download <a href=".$file_path." download>Here</a>"; When parsed, this turns into: <a href=path/to/file download>Here</a> True, technically attributes don't need to be enclosed in quotes (last time I checked - that may be wrong now), but it is generally considered a good idea.
  24. maxxd

    array hierarchy and filter

    I haven't done any php DOM manipulation or parsing in quite some time and as far as I can recall I've not used the Simple HTML Dom Parser library (usually just use DOMDocument), but from the docs it looks this could be what you're looking for: foreach($html->find('li') as $li){ print("<p>{$li->first_child()->innertext}</p>"); } The first_child() of each list item element should be the anchor tag, and innertext should return the contents of that anchor tag. Unless I'm not reading something correctly - it's been a long day, so it's very possible that I am...
×

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.