-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
In my experience, from both an API and UI-based perspective, MailChimp is much easier to use than Constant Contact. Just a personal opinion on the matter, but I will always lean towards MC over CC.
-
php only works when i’m logged into wordpress.
maxxd replied to davidhb21l6's topic in PHP Coding Help
Depending on what theme you're using, it's very possible that that exact code is duplicated across multiple templates, so you could be in the wrong file without knowing it. WordPress doesn't exactly require - or even in a lot of ways promote - good practices when it comes to PHP and coding for the web. And some of the Automattic plugins are the worst offenders (WooCommerce, I'm looking at you), so don't assume it's good just because it came from the same company as WP or it's got a lot of stars. -
php only works when i’m logged into wordpress.
maxxd replied to davidhb21l6's topic in PHP Coding Help
Also, <%php is not the correct opening tag. Use <?php. However, sounds like requinix is right - you're in an admin or restricted area of the template. What's the file name and location you're working with? -
Your while() criteria is incorrect and unnecessary. I haven't tested this code, but give it a shot: $acceptedStates = [ 'Feasibility', 'Measure Up', 'Model Drawing', 'Concept Design', 'Developed Design', 'Resource Consent', 'Construction Documentation', ]; $xml = simplexml_load_string($response); $xml = usort($xml, function($a, $b){ return $a['job_due'] <=> $b['job_due']; }); foreach($xml->Jobs->Job as $item) { if(!in_array((string)$item->State, $acceptedStates)){ continue; } $projects[] = [ 'job_no' => (string)$item->ID, 'job_name' => (string)$item->Name, 'job_due' => date('d/m/Y', strtotime($item->DueDate)), 'job_status' => (string)$item->State, 'job_staff' => (string)$item->Assigned->Staff->Name, ]; }
-
Error establishing a database connection - wordpress-issues
maxxd replied to dil_bert's topic in Applications
So, clearly you're working with WordPress for this project. WordPress has enough issues and pain points by and of itself - why are you making it harder on yourself? If you're actually (as it seems) working within the WP infrastructure, why not just use the WordPress database object? The connection to the database is already made, you can use it like an ORM (kinda), and depending on how you use it, it kinda sorta sanitizes database interactions by default. The reason you'll see a check in most WP theme and/or plugin files for the ABSPATH constant is to make sure the WordPress core has been loaded. If you're trying to do something within WordPress before the core is loaded, I'd recommend looking at why you're trying to do it and why it needs to be done exactly then. I hope that makes sense, and sorry if I'm missing the point of what you're actually trying to do, but it really seems like you're making things much more difficult than they need to or should be. -
Error establishing a database connection - wordpress-issues
maxxd replied to dil_bert's topic in Applications
Is there a reason you're not using the WordPress database class? -
Woocommerce New Order Table Heading Background Color
maxxd replied to BySplitDecision's topic in Applications
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. -
How to add the ability to login with username or email for login?
maxxd replied to Jedijon's topic in PHP Coding Help
That is true... -
How to add the ability to login with username or email for login?
maxxd replied to Jedijon's topic in PHP Coding Help
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. -
How to add the ability to login with username or email for login?
maxxd replied to Jedijon's topic in PHP Coding Help
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. -
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.
-
@cyberRobot - I had the same thought about the 'download' attribute, but looking it up on MDN it's a legit attribute.
-
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.
-
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...
-
Another option would be to record the package cost to the customer with the specific customer row. A 'current_rate' field or a many-to-many table with `customerID`, `planID`, and `rate` fields. This way you could give discounts or charge somebody more depending on what mood you're in.
-
Give this a try: $li = $html->find('li'); print("<p>{$li[0]->children[0]->attr['href']}</p>"); and see if you can follow the track through the output of the var_dump() function. Then try this: $li = $html->find('li', 0); print("<p>{$li->children[0]->attr['href']}</p>"); and follow that as well. Coupled with the documentation and the comments above, things will hopefully start to look a little clearer...
-
They weren't intended to be copy and paste solutions. They were a mashup of the documentation and your code with the goal of showing you how the function call needs to be made to get you the results you want. Read the code, read the documentation, then apply logic. As @gw1500se says, $str1 isn't a string, it's an object with some properties that are arrays and it needs to be treated as such.
-
It sounds like you're determined to make each package option an element of a form the sole purpose of which is to select a plan, just so you can use $_POST to get the value the user selected. My point is that you don't have to deal with form actions or button elements - just make each choice a link. Style it however you want, then pull the selection from $_GET on the target page and go from there. It's not a huge thing, but it's slightly less typing and potential troubleshooting for you and, from a coding and semantics perspective, it makes more logical sense.
-
Look at some sites using that method (InMotion hosting comes to mind immediately). They're mostly links to pages, not buttons in a form. It seems like you're introducing quite a bit of unnecessary complexity to a fairly simple pattern. If you really wanted to, you could always just set the package to a session variable on load at the target pages from the comparison links (I hope that makes sense).
-
Take a look at how you're making the call and how the documentation makes the call. I've updated the examples a bit to make the comparison more direct, I hope. Yours: $li->find('a')->first_child(); Theirs: $li->find('a', 0)->first_child(); And the error message: Call to a member function first_child() on array And finally, the documentation itself states (modified for emphasis): Hope that helps.
-
I got a message with the actual code we've requested here... OP - if you want help with the task, post the code here and let all of us take a look at it. More eyes = more help, but remember this is your homework. So we will help, but we won't write it for you.
-
Think it through. One of the things you'll see and hear about regularly in programming is 'pseudo-code' - write the steps you need the program to follow in order to solve the problem, then write the code to actually do it. So what do you need to do here? for the first 50 units of energy energy used add .10 to the total bill are there units left to bill? for the next 100 units of energy used add .15 to the total bill are there units left to bill? for the next 100 units of energy used add .25 to the total bill are there any units left to bill? for the rest of the units add .35 to the total bill take the total bill and mulitply it by .2 to figure the VAT add the VAT to the total bill output the total bill You need to look at conditional logic and math functions. There's a bunch of different ways you can do this, so write some code and post it here. If your throws errors post those, too.
-
This means that the return value of PT_Secure($_GET['page']) is always 'category'. The problem is with PT_Secure() - check the documentation to make sure it's being used correctly.
-
If you're visiting the 'trending', 'latest', and 'top' pages and seeing 'HELLOcategory text here' on all three (or any of the three, actually), then something is wrong with either PT_Secure() or your use of it because the value of $page is never not 'category'. Change die("<pre>".var_export($page, true)."</pre>"); to print("<pre>".var_export($page, true)."</pre>"); then visit the 'trending', 'latest', and 'top' pages and compare the output.
-
The goal has been achieved. The script is doing exactly what you've said you wanted - you're printing custom text on each of the three specified pages; you're just not testing from one of those three pages. If you need custom text per page and don't want to limit it to the three listed pages, you'll have to account for those pages in your conditional logic.