Jump to content

kicken

Gurus
  • Posts

    4,696
  • Joined

  • Last visited

  • Days Won

    178

Community Answers

  1. kicken's post in email acknowledgement - follow-up was marked as the answer   
    Did you enable remote content in your email client?  Most block it by default as far as I know.
  2. kicken's post in Method for email acknowledgement was marked as the answer   
    There is no sure-fire way to accomplish what you want to do.  Whatever methods that do exist to try and automatically determine this are typically blocked or otherwise made useless for user privacy reasons.  Many email clients for example will not load remote images by default, so your tracking pixel would not work.  I think gmail takes the opposite approach and always loads the images, whether the email is read or not so it similarly provides no insight as to whether the user opened the email.
    You can add a tracking pixel to try and catch the few people using a client that will still load it.  Otherwise the next best option is to add tracking data to all the links inside the email so if they click any of the links you will know about it.  Even that type of tracking can sometimes be bypassed by clients.
     
  3. kicken's post in New SQL creation problem was marked as the answer   
    Use LEFT JOIN instead of inner join for the joints to the sub-queries.  You'll get NULL for reps with no sales.  You can convert that null to a 0 in the select clause if you want by using COALESCE.
  4. kicken's post in Why doesn't Element's "style.left" work? was marked as the answer   
    The .style.* properties only provide values directly assigned to an element, either via JS or via a style="" attribute, they do not reflect CSS applied via selectors.  For that, you need to use getComputedStyle.
    I do not see anything in your current code that is changing the left attribute of your elements, so it'd never change to be zero.  Scrolling does not affect the left attribute of an element if that was your intent.  If you want to check if something has been scrolled out of view, you need to find the scroll position and compare it to the position of the element.
     
  5. kicken's post in How would I do post-specific custom names? was marked as the answer   
    Sounds to me like you have the correct solution as far as the DB is concerned, it's just your framework choice that is the issue.  I use Symfony/Doctrine and it could handle this setup no problem.
    If you can't do what you want using Laravel's setup, you may need to just resort to doing some manual queries.  I don't use laravel so can't say for certain if this really is a limitation or how to work around it.
     
  6. kicken's post in Retrieve user’s password as part of a Cybersecurity challenge was marked as the answer   
    Seems the password is being written in clear text to a file.  All you need to do then is read that file.
  7. kicken's post in Why value returned in preg_replace_callback is string ? was marked as the answer   
    The function you want is preg_split, not preg_match_all or preg_replace_callback.
     
  8. kicken's post in Notice: Only variables should be passed by reference was marked as the answer   
    INSERT queries do not have a result set.  As such, mysqli_stmt_get_result returns false, as documented.
    To check if a row was inserted, use mysqli_stmt_affected_rows.
  9. kicken's post in Syntax error: unexpected token 'include' was marked as the answer   
    Please do not post screen shots of your code.  Copy and paste the relevant parts of your code into your post using a code block (the <> button).  That picture is barely readable.
    As for your issue, you are missing the semi-colon on the line above.
  10. kicken's post in PHP beginner was marked as the answer   
    The main issue with your code is how you're trying to find the days element.  To explain a bit, lets look at how your HTML gets rendered:
    <div class='month-container'> <div class='days' id='Vendémiaire'> <div class='day'>1<span class='name'>Raisin</span></div> <div class='day'>2<span class='name'>Safran</span></div> <div class='day'>3<span class='name'>Châtaigne</span></div> <div class='day'>4<span class='name'>Colchique</span></div> <div class='day'>5<span class='name'>Cheval</span></div> </div> <div class='month'>Vendémiaire</div> </div> You are attaching your click handler to the div.month element.  That means in your click handler, el is going to reference that element.
    To try and find the days element, you are looping over the nextElementSibling property until there are no more siblings.  Think about that for a moment.  nextElementSibling is going to find the elements that come after the current element.  What comes after div.next?  Nothing.  You need to be looking at the previous siblings, using prevElementSibling.
    Now, once you find your days element, you have another problem.  You are testing if it's style.display value is equal to "none".  One might think this should be true since you have applied display: none; in your css, but it's not.  The reason is that the style properties on the element only refer to styles applied directly to that element via a style="" attribute, not anything inherited via css selectors.  Since no direct style was applied to your element, the style.display will be the empty string, fail your condition, and you'll set it to display.  On a second click, it would pass and you'd set block and your toggle would start working.  Reversing the conditional would fix this double-click issue.
    ---
    Now that the issues have been pointed out, there are other things of note and also general ideas that should be applied to make this better.
    You have both an onclick="" attribute and an addEventListener call on your month elements.  You should only have one, and the preferred method is to use addEventListener in your code and stop using the on* attributes.  It should be removed, notice I didn't include it in my example html above. Your loop to find the days element is unnecessary.  The way your HTML is structured, the days element will be simply el.prevElementSibling, no looping required.  If you want to add other elements between your month div and the days elements, a better approach would be to use querySelector on the parent element: el.parentElement.querySelector('.days'); Dealing with style properties directly should generally be avoided if possible.  Changing the applied classes is a better approach.  For something like this, create another class that sets display to block which can be applied to your days element.  You can then use javascript to toggle this class on and off. .days.visible { display: block; } days.classList.toggle('visible');  
    You can view the above suggestions implemented in this demo fiddle.
     
  11. kicken's post in First and last of a div with an assigned class... was marked as the answer   
    The container needs to contain only your .update_card elements, and those elements must be direct children of the container.
    Your original HTML doesn't meet those requirements.  The .blw element also contains your .update_grade element (which is the :first-child).  Your screenshot suggests every .update-card is wrapped in some other parent element (hence, they all are :last-child of that container).
     
  12. kicken's post in Should composer classes ever be used in an application? And if so, how? was marked as the answer   
    You can use composer stuff, you'd just need to add the "composer/composer" package as a requirement to your project.
    If all you need is the class map stuff, that is it's own component (composer/class-map-generator) so you could include just it instead.
     
  13. kicken's post in 2 Emails was marked as the answer   
    Neither of those is a valid email address.  Your attempt at $to has extra '..' surrounding the email.  Your attempt at $from has no local part (before the @).
    I would highly suggest using a library to handle your emails instead of trying to use mail() directly.  Symfony/mailer is my choice.
     
  14. kicken's post in Stuck on my next step for quiz app was marked as the answer   
    You can generate whatever HTML you want and swap it out using the JS code.  The HTML structure in my example is how I'd probably code it, but nothing about it is required.  You'd need to adjust the JS to match up with whatever your final HTML is with regards to the classes/IDs etc.
     
    There are a variety of ways to handle the next question bit. You could include a link to the next question when loading the current question.  You could load a list of question IDs when the page first loads and use JS to walk the list.  You could load the questions by a display number (1, 2, 3, ...) and just keep incrementing it until you get a 'No more questions' response.
    Since you already have code to load a question by it's ID, one of the first two options might be easiest to implement.  The first option would keep you coding mostly in PHP by just returning a link for the JS to follow.  The second involves a little more JS work to walk the list of question IDs.
     
  15. kicken's post in Responsive CSS on iphone was marked as the answer   
    If I am understanding the problem right, then it sounds like there's some element on the page that cannot be scaled down so the entire page gets scaled down so that element will fit.  Examples could be form elements or images with set widths.  My site for example has a couple pages with textarea elements that cause the page to not display scaled down on mobile.  Adding width: 100% to them in the mobile styles would fix it, I just haven't done it.
  16. kicken's post in Javascript and database help was marked as the answer   
    This is something from the days of Internet Explorer.  It will not work on any modern browser.  If you want to use a local database, use IndexedDB.
  17. kicken's post in I have create a page where it is suppose to render the infromation from the database accroding to the id of the selected item, Help was marked as the answer   
    If you want to use /api/houseinfo/1 as your URL, then you need it have that mapped by the server to /api/houseinfo.php?id=1.  This is typically done using a URL rewriting feature of your server software. For apache, that is mod_rewrite.
    Since you're getting a 404 when using /api/houseinfo/1, that implies such rewriting is not taking place.  Either you have not configured it, or have configured it incorrectly.
     
  18. kicken's post in Cookie “PHPSESSID” does not have a proper “SameSite” attribute value. Soon, cookies without the “SameSite” attribute or with an invalid value will be treated as “Lax” was marked as the answer   
    All your cookie code there is redundant.  session_start manages its own cookie, you don't need to do it yourself.
    You can control the SameSite value either using the configuration option session.cookie_samesite or the session_set_cookie_params function (before calling session_start).  Example:
    session_set_cookie_params([ 'lifetime' => 0 , 'path' => '/' , 'domain' => '.site.com' , 'secure' => true , 'httponly' => true , 'samesite' => 'Lax' ]): session_start();  
  19. kicken's post in Up to 6 Numbers followed by a letter was marked as the answer   
    The braces specify a repetition range, like so: {min[,max]}.  If you only set the min value then it is an exact count.
    So what you have says match exactly 5 digits, no more and no less. Presumably, you'd want to instead match between 0 and 5 digits, assuming something like 8M is valid.  To do that, you set both values accordingly.
    \d{0,5}  
  20. kicken's post in Error: 'id"... is not valid JSON was marked as the answer   
    You are not passing the ID of the record to delete in your delete request, so your script is returning the error text "Error: 'id' parameter is missing in the request."
    Your Javascript code is expecting the response to be JSON data.  Your error message text is not JSON data, so trying to parse it as JSON throws an error.
  21. kicken's post in I need help my registration page, no data is getting inserted in the database was marked as the answer   
    upper-case N Name is not the same as lower-case n name.
     
  22. kicken's post in CSS, DIV and fully resizeable was marked as the answer   
    Presumable that would be in whatever .css file you imported into your page to make those classes available to you in the first place.  You could just use the browser's dev tools to inspect the elements and see the rules and properties applied too.
    Have you looked over the documentation?
     
  23. kicken's post in Make youtube video play on click of image was marked as the answer   
    The variable is undefined because of how variable scope works in JS.  Variables are limited to the function they are defined in.
     
    Regardless, you shouldn't be typing that into the console, it should just be part of your script.
     
  24. kicken's post in PDO connection with error check was marked as the answer   
    Why do you think it wouldn't work for other errors?  It says in the manual
    It doesn't say it throws on invalid username/password, it says it throws on failure.  Invalid username / password is only one of many reasons why the connection attempt might fail.
     
  25. kicken's post in PHP and Text (txt) was marked as the answer   
    This is wrong.  fopen returns a resource, but file_get_contents wants a filename.  This should be triggering a warning and/or error for you (depending on PHP version), something like:
    if you cannot see that warning/error in your output or in PHP's error logs then you need to adjust your error reporting settings for your installation.
     
    If you want to use file_get_contents to read a file, then you don't fopen it first, you just call file_get_contents.
    $contents = file_get_contents('accounts.txt'); If you want to fopen the file (for example, so you can lock it) then you need to read the data using fread, fgets, stream_get_contents, or similar.
×
×
  • Create New...

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.