-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
You have to wait until a document element is loaded in the DOM before you can use it or interact with it. Look into window.onload.
-
cron.php is a standard file in WordPress installs, so if it's suddenly missing from the wp-includes directory then it got deliberately removed. I recommend re-installing WP and examining your logs for deletes or unusual/suspicious logins.
-
Trying to pull URL from DB and use in <IFRAME>
maxxd replied to endorush85's topic in PHP Coding Help
<iframe width="420" height="315" src="<?php echo $row['url']; ?>"></iframe> This is a basic example - there are other, better ways to do this. For instance, the short echo tag is easier to read. The best idea is to use a template language like Twig, but that is a far more advanced operation. You'll also want to look into escaping your output as well. -
I''m pretty sure there was no information falling out - the person you were talking to was more than likely talking about at least two completely separate things. Flexbox has nothing at all to do with backgrounds; it's a two-dimensional layout system. Browser CSS support has gotten strong enough that CSS can do a lot of things these days (certainly much more than it could even just a short few years ago) and those things can affect pretty much every aspect of a page. Take some time to learn the basics. Even if you're a dedicated back-end developer working with a dedicated front-end developer, knowing how a page is structured and what can be done with that structure can help you determine how to collate and present to the front-end the data you pull from the back-end.
-
If you're talking about the page background with the logo on the wall and the lamp; it's set up in the CSS using media queries. Inspect the element and resize the browser window; you'll see it's serving different images at different browser widths - this is a common practice in modern web development.
-
I'm sure this isn't as easy as I'm making it out to be, but try to break it down to the basics. The command words in PHP don't change regardless the language spoken by the coder - the variable names and comments will change, but the command words don't. So don't worry about the specific command words while you're starting out. Learn what the constructs do, then learn what they're called. Think about is like this: a variable is learned knowledge that can change at any time if/when you learn something new a function is an action, more often than not done with and dependent on the knowledge you have from your variables at that point in time a control loop is the thought process about what to do and why to do it; it's heavily influenced by your variables and dictates the function that is performed a statement is kind of common knowledge or social agreement - it's an expected, repeatable outcome no matter the conditions around it This is massively simplified, but in my experience it's helped some people to step back and explore the basics before they start actually learning programming. After that, you can figure out when to use a for loop as opposed to a do or while loop - those are some of the command words you'll be dealing with. Disclaimer: Not gonna lie, I accidentally posted this halfway through typing it and then I had to edit it to finish it and I hope nobody was notified on the first post. I even though about deleting it entirely because english is my first (and only, unfortunately) language and most tech documentation I came across in my learning was in english so it was easier for me. Hopefully the above makes some sense, is contextually correct, and helps.
-
It means $wp_query is null at the time the function is called. If I'm remembering correctly, this can happen if your function is called before the 'posts_selection' action is fired - if you're not in the loop.
-
Just from the sample on Amazon it looks like the book defines the terms you'll need to know pretty quickly - function, variable, statement, control loops, etc. The thing to remember is that none of these are specific to PHP so if you can find a good general introduction to programming in your native language you should be able to get enough to start understanding the specific things PHP does with all the general constructs. I hope that makes sense.
-
Also, 'Allowing users to register accounts' seems to be a very specific thing that can vary a lot depending on the system/setup you're using. What's the name of the book you're using?
-
I believe Pusher is your best bet if you're determined not to use websockets, although there may be a better solution these days.
-
So, it looks like there are a lot of things going on here. First off, when you create an array you want to wrap the string values in quotes. This alone should be throwing an error about undefined constants. Now, inside your function you refer to the array you created outside the function. This should also be throwing an error about an undefined variable - the $array1 array doesn't exist inside that function. Read up on variable scope - it's an important concept. What you need to do is see what exactly the $field_ids parameter contains and what the values correspond to. You can do that by adding this right after the opening bracket in the function signature: die("<pre>".var_export($field_ids, true)."</pre>"); Then remove the appropriate value from the $field_ids array (not $array1 - that doesn't exist in this function, remember) before you return it. Most importantly, on your development machine open the file 'wp-config.php'. Look for a line that reads `define( 'WP_DEBUG', false );` (in the sample file it's on line 82) and change it to read `define( 'WP_DEBUG', true );`. This will let you know when errors like the above happen.
-
Function if comparision outputting false value incorrectly.
maxxd replied to Adamhumbug's topic in PHP Coding Help
I'm pretty sure I don't understand the issue you're having, but right off the top I see this. This is your function definition: function getItemsForQuote($itemType, $currency, $qty = null, $startDate = null, $endDate = null, $itemId = null, $notes = null) and this is what you're calling: getItemsForQuote($item['itemType'], $item['quoteCurrency'], $item['quantity'], $item['itemId']); You're passing the itemId as the startDate parameter. -
I initially went with concatenation because best practices in HTML recommend using double quotes for attribute values so far as I recall. All that having been said, obviously this becomes much easier using a template framework like Twig or Blade. <option value="{{ $myrow['cats'] }}">{{ $myrow['cats'] }}</option> Not only that, both escape output by default.
-
Groovy - I'm genuinely glad that works and helped you out. Now for bonus points, can you explain why it works?
-
This is one of the major problems with echoing html from within php - your quotation marks are getting lost/confused. If you have to do this, remember using single quotes is perfectly appropriate for an echo statement in php even though it won't interpolate variables. In your case, this is fine as you're using concatenation. Try this: echo '<option value="'.$myrow['cats'].'">'.$myrow['cats'].'</option>'; This way it's easier to see that there are quotes around the option value so you know that spaces in the value won't break the entire thing (which is what's happening to you now). It's also a best practice in html to use double quotes for attribute values, so that's cool too. I made the quotes around the array indexes single quotes; I'm not entirely sure that's best practice for php but it's what I've seen most often and what I personally prefer, so...
-
If you're specifically looking for a title attribute and not the post body itself, I'd look at adding a maxlength attribute to your input field. You'll want to validate and, if necessary, truncate the text on the server side as suggested by Barand (or just reject the input wholesale) because there are ways around the browser, but it's a start. Admittedly from what I see the title doesn't seem to be the issue in the screencap you posted, so I'll say if I'm misunderstanding what you're calling things and you're referring to what is typically the post body you'll probably want the WP-specific the_excerpt function.
-
Is the issue that it's showing too much content or that it's overflowing on the right edge?
-
Not to mention WP's get_option() function allows a default in it's signature so the entire convoluted second ternary isn't necessary. $coronavirus_notice_banner_color = (!empty($_POST['action']) && $_POST['action'] == 'save_coronavirus_notice_plugin') ? $coronavirus_notice_banner_color : esc_html(get_option('coronavirus_banner_color', '#cc0000')); Either way, did you recently update your version of PHP or is this a recent plugin addition to your site? The way it's set up isn't supported anymore - PHP used to do it's best to figure out import in nested ternary operations, but it doesn't now. It needs to be explicit by way of parenthesis.
-
OK, so when you went down to the basement your parents had previously said it was ok for you to drink soda. You weren't looking for - and at that point didn't want to drink any - soda but you decided (understandably) that you might want some later, so you brought it up. Cool. Problem is, between the time you brought the soda up from the basement and the time you decided you actually wanted to drink it, your parents decided you shouldn't have it. Check permissions every time you do something or expect bad things to happen. If someone logs in with certain rights and abilities, don't expect they'll log out before you change those rights and abilities.
-
OK, so unfortunately Carbon doesn't have a native formatter for that. So one way or another, I think you're going to have to touch all of your models as they all extend from Illuminate\Database\Eloquent\Model and if you override that base class you'll have to update all the use statements. That being the case, I'd look to either global scopes or accessors to handle your case.
-
According to the documentation, Laravel automatically casts the created_at and updated_at columns into Carbon instances. I don't know what 'solar history' means, but it's possible the hard work is already done and all you've got to do is format the field as desired.
-
What change are you trying to make on the created_at field?
-
Depending on what it is you're trying to do with the data, there are several ways to change a field. You can set up an accessor or mutator or use a query scope, for instance. Query scope sounds like what you're looking for, although should worse comes to worst you could just write a trait and use it on your model instances where needed.
-
Need help with an ancient news CMS [flat files for db, no mysql]
maxxd replied to xDx's topic in PHP Coding Help
Certainly not trying to be an ass, but if it's so old the support forums are defunct you can pretty much guarantee there are major issues with it. I'd have to bet the biggest problem you're running into is that PHP has moved on - php 5 will mostly work on a php 7.x environment, but I wouldn't bet the bank on it. If you value your time, change your CMS - there are a lot out there. WordPress is everywhere and simple to use, so there is a ton of documentation as well as an absolute boatload of themes and plugins. If you're being safe it's not quite plug-n-play, and I do recommend reading the reviews on any themes and plugins you may use, but it's a decent starting place if you just want a site up. With just over 160 articles, it shouldn't be too difficult to migrate (even manually). And at least you won't have to spend most of your time trying to duct tape defunct and deprecated code while simultaneously putting the entire server in harm's way by using dangerously out-of-date code.