Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. Your questions seemed to be about what is a good practice. I believe that's already answered. If that code is working for you then there's no need to change it. The properties exist in his code and are being used correctly, the only problem is that he didn't declare them, which PHP seems to allow. The constructor is creating them using the arrow "->" syntax. The only change necessary would be to declare those properties. class rss_feed { // Declare properties here: private $db_settings; private $xmlns; private $channel_properties; private $site_url; private $site_name; private $full_feed; /** * Constructor * * @param array $a_db database settings * @param string $xmlns XML namespace * @param array $a_channel channel properties * @param string $site_url the URL of your site * @param string $site_name the name of your site * @param bool $full_feed flag for full feed (all topic content) */ public function __construct($a_db, $xmlns, $a_channel, $site_url, $site_name, $full_feed = false) { // Assign to properties here: $this->db_settings = $a_db; $this->xmlns = ($xmlns ? ' ' . $xmlns : ''); $this->channel_properties = $a_channel; $this->site_url = $site_url; $this->site_name = $site_name; $this->full_feed = $full_feed; }
  2. What he's listing in the comment are the function parameters, not the class properties. However, he hasn't declared the class properties in the class definition. Although PHP might let that slide, it's not a good idea. You should declare class properties outside of the constructor. For XML based applications I would recommend against using strings for it. I use DOMDocument to generate XML for me.
  3. Ingolme

    Local files

    What code are you using to include these files?
  4. You validate the length before hashing it. There's no reason to do anything with a password after it has been hashed outside of comparing it to another hashed string.
  5. You don't encrypt passwords, you hash them so that the information is irrecoverable. Since passwords are never printed anywhere, any character is valid because there is no risk of injection.
  6. This code won't run, those are syntax errors, except the ones that are outside the <?php ?> tags. It looks like something that passed through some other software and is supposed to be stripped out before running.
  7. Ingolme

    CSS Coding

    Start off by reading the CSS tutorial.
  8. With pure Javascript there's a window method called saveAs() which isn't widely supported by browsers. I can't see any reference to this method on the MDN so I'm not even certain if it's a standard. Somebody built an example with a cross-browser polyfill here: https://codepen.io/davidelrizzo/pen/cxsGbI It's not exactly a library, just a fallback function that's used if the browser doesn't have native support. If you have a server-side language available you can submit a form to an invisible iframe, have the server generate the data and serve it with a "Content-Disposition: attachment" header. Here's a very simple PHP example: <form action="save-file.php" method="POST" target="filesaver"> <div> <label>Filename: <input type="text" name="filename"></label> <label>File content: <textarea name="data"></textarea> </label> <button type="submit">Save</button> </div> </form> <iframe name="filesaver" width="1" height="1" frameborder="0"></iframe> <?php // This is save-file.php $data = $_POST['data']; $filename = $_POST['filename']; header('Content-Disposition: attachment; filename="' . $filename . '"'); echo $_POST['data']; ?>
  9. This sounds like a very bad way to build a website. You really would be best off rewriting the HTML, but if you only want to target elements with a particular attribute value, use the attribute selector: font[size=6] { font-size: 18px; line-height: 18px; font-family: Verdana, sans-serif; }
  10. The parameters in the for loop are optional. There are several ways to solve the problem. You can add the x right before appending to the string: txt += "input" + (i + x) + "<br>"; You should cast x to a number before the loop to prevent it from being used as a string.
  11. I'm not at my computer so I can't debug the page, but the problem seems to be the phone bar at the top of the page. Use the DOM inspector to see what styles are being applied to it.
  12. Without any code or access to the page I can't tell what the problem is. It might be some margin or padding on any of the elements.
  13. Is ResizeImage() a function? Usually by convention class names start with an uppercase letter while function names start with lowercase. If it's a function. what type of data does it return?
  14. It would be helpful to know what the error message says.
  15. This works for me: <div class="w3-content" style="max-width:1200px"> <img class="mySlides" src="img_nature_wide.jpg" style="width:100%"> <img class="mySlides" src="img_fjords_wide.jpg" style="width:100%"> <div class="w3-row-padding w3-section"> <div class="w3-col s6"> <img class="demo w3-opacity w3-hover-opacity-off" src="img_nature_wide.jpg" style="width:100%" onclick="currentDiv(1)"> </div> <div class="w3-col s6"> <img class="demo w3-opacity w3-hover-opacity-off" src="img_fjords_wide.jpg" style="width:100%" onclick="currentDiv(2)"> </div> </div> </div> </div> Just change the s4 classes to s6.
  16. You can animate the background position, that's how Bootstrap makes progress bars.
  17. No, they won't be animatable under the current specification because they are part of the background image property which is not animatable. I use Javascript to animate gradients.
  18. That code will prevent the function from running as long as there's any value different than the button that was pressed. As dsonesuk pointed out, Javascript has a built-in function called indexOf() to detect if an element exists in an array which I forgot since I've been programming in lower level languages lately. This is how it would work: var value = button.getAttribute("data-value"); if(panels.indexOf(value) != -1) { // Add the button's value to the array panels.push(value); // Display the contents of the array on the page by generating <li> elements. // ... }
  19. Each time you click a button you will have to loop through the panels array and compare its elements with the button's value. If the value was found then don't add it to the array. A for() loop and a boolean variable should be enough to do that.
  20. In Firefox at 375px wide the green text overlaps the black text. For the most flexible and consistent layouts I would suggest not using absolute or fixed positioning.
  21. You should only need one function. First set up your buttons to each have a value: <button type="button" class="add-panel" data-value="4 Panel Smooth">Add 4 Panel Smooth</button><br><br> <button type="button" class="add-panel" data-value="4 Panel Grained">Add 4 Panel Grained</button><br><br> <button type="button" class="add-panel" data-value="4 Panel Grained 2 Glazed">Add 4 Panel Grained Glazed</button><br><br> Create the list that will contain the values: <ul id="demo"></ul> Set up an event listener for the buttons: var buttons = document.getElementsByClassName("add-panel"); for(var i = 0; i < buttons.length; i++) { buttons[i].addEventListener("click", addPanel, false); } Create the event handler that updates the array and displays its contents in the HTML: var panels = []; function addPanel(e) { // Get a reference to the button that was clicked var button = e.currentTarget; // Add the button's value to the array panels.push(button.getAttribute("data-value")); // Display the contents of the array on the page by generating <li> elements. var demo = document.getElementById("demo"); demo.innerHTML = ""; var li; for(var i = 0; i < panels.length; i++) { li = document.createElement("li"); li.innerHTML = panels[i]; demo.appendChild(li); } }
  22. Can you describe what's different in your iPhone? I don't have an iPhone to test on. Phone screen sizes may vary. Common sizes are 375px and 320px. When I'm emulating phones I put those widths in the responsive design tool for testing.
  23. If you're getting a blank page that means PHP had a fatal error. You should be able to see what the error was in your server's error log and start debugging from there.
  24. I would have expected the person who wrote the query to have enough SQL knowledge to implement the solution I gave in my previous post. The last few words of my post are literally SQL code.
×
×
  • Create New...