Jump to content

iwato

Members
  • Content Count

    1,452
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. Have you tried inserting the following var_dump($query); after the expression $query = $select ->fetch(); to see, if anything is contained therein? Roddy
  2. BACKGROUND: I have an HTML document whose <html> element is tagged with an event icon (EV) when viewed in Firefox's Inspector panel. The <html> has no properties of its own. When one clicks on the event tag one can read the following: The above code appears to refer to a Matomo script placed inside the documents <html> tag at the bottom of the page. The phrase itself is followed by two buttons called Bubbling and Dom2. When one clicks on either a drop-down panel appears with the following code function af() { var al; m = true; aa("unload"); if (r) { do { al = new Date() } while (al.getTimeAlias() < r) } } QUESTION: Can you explain this phenomenon? What is going on? Roddy
  3. Yes, I see. A visitor may wish to view the page in a language different from that of his own browser. Is this what you mean? Roddy
  4. Got it! Thanks. But, you did not answer my first question in the last entry. Is the result not the same? Roddy
  5. OK. But, would you not agree that both longhand interpretations produce the same result? Also, how did you get to $str_browser_language = ''; and $str_browser_language = $str_browser_language; Roddy
  6. CHALLENGE (WELL, KIND OF): Please find below two sets of code. The first is a short-hand snippet of code fits that within a larger block of code. The second is my own long-hand interpretation of what it means. SHORT-HAND: $str_browser_language = !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ',') : ''; $str_browser_language = !empty($_GET['language']) ? $_GET['language'] : $str_browser_language; LONG-HAND: if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $str_browser_language = strtok(strip_tags($_SERVER['HTTP_ACCEPT_LANGUAGE']), ','); } else { if (!empty($_GET['language'])) { $str_browser_language = $_GET['language']; } else { $str_browser_language = ''; } } QUESTION: Is my interpretation correct? If not, please explain, in what manner I have erred. Roddy
  7. I can do as you suggest, but have no idea why it would change anything. The Custom Search functionality for Newsletter, Podcast, and Q&A is, with the exception of several variable names and values, identical. What changes is only the content that is uploaded only after a match has been made. The problem occurs before any match is made occurs on only to of the three search engines. Roddy
  8. I have scoured the relevant page -- namely, overview.html -- and can find no difference. I am at a complete loss. Roddy
  9. BACKGROUND: I use phpMailer in multiple locations or multiple purposes on my website. For example, sometime it is a mass mailing that requires a connection to my MySQL data base, sometimes it is a simple one-on-one communication between me and a new visitor, sometimes the sender is newsletter@grammarcaptive.com, and other times the sender is admin@grammarcaptive.com, etc. Now, I develop in a folder that is a subdomain of the main domain of my webpage. As a result, the path to my Composer installation is different for my development and production sites, and I cannot simply copy from my subdomain to my main domain and expect anything to work. In order to avoid the resulting path problem I would like to extend the phpMailer class. In addition, I would like to avoid the redundancy of copy and paste for everything required to make phpMailer work. For example, one can expect that SMTP server settings will always be the same and the reply recipient is not expected to change. Further, the data base when it is used will always be the same, even though the table is likely to change. REQUEST: Could you sketch in code form what a plausible class arrange would be? NOTE: That last time i tried this it failed, for a lack of a proper outline. Roddy
  10. You appear to have left out the href attribute. Try the following: document.write('<a href="' + link + '" target="_blank"><img src="' + adBanner + '" width="125" height="125" alt="' + alt + '" title="' + title + '" /></a>'); Roddy p.s. If it helps, hover over the heart and click on the trophy that results.
  11. BACKGROUND: I have, somewhat miserably, copied code from one document to another and changed a word in multiple locations in the copied code in an effort to adapt to a different environment. Unfortunately, the result of the copied code is not identical with the result of the code that was copied. Now, there are obvious places to look for the discrepancy, and this I have surely done. Still, I can not find the source of the discrepancy. In an effort to duplicate my frustration, please follow the steps below: STEP ONE: Open to the Grammar Captive mainpage. STEP TWO: Find the navigation bar on your left and the menu item named Local Search. STEP THREE: Click on the word Newsletter. STEP FOUR: Enter into the appropriate box the number of the word-number phrase and click on the SEARCH button. DO NOT enter a keyword! STEP FIVE: Watch how the main content scrolls to the bottom of the respective div. STEP SIX: Repeat STEPS ONE thru FOUR, but in STEP THREE, click on the word Podcast. STEP SEVEN: Notice the absence of scrolling. This is the preferred behavior. QUESTION: What is causing the div to scroll in the one case, but not the other? Roddy
  12. Your suggestion about invoking the reset function when the div is loaded works, but it also seems to render a lot of the rest of what I did worthless. Now, I have to figure out what to eliminate. Roddy
  13. "BACKGROUND: I have a page that, when loaded, creates several values via PHP. These values are assigned to several Javascript variables on the same page. I have verified that the assignment succeeds.  When a visitor clicks on the page a visible div on the page is filled with the content of another div on the same page page, and additional javascript and CSS are loaded from another document."  Roddy
  14. Yes. The reset button sets the captcha question and answer after the search div has been already loaded. The original question and answer are determined when the page is loaded. The functionality is similar, but the activation is different. The reset button uses AJAX to trigger the generation of the question and answer. The initial setting does not. This latter is generated with PHP built into the main page. Roddy
  15. OK. I have uploaded the problem to the internet. Please proceed as follows to discover the source of the problem. STEP ONE: Open to the Grammar Captive mainpage. STEP TWO: Find the heading Local Search in the navigation bar and click on the menu option Newsletter. STEP THREE: Find the Captcha fieldset and click on the Reset Button . STEP FOUR: Play to your heart's content. Everything is, at minimum, functional. STEP FOUR: Repeat STEPS ONE and TWO. STEP FIVE: Skip STEP THREE and proceed to STEP FOUR. This is where the problem arises. It is because the condition of the if-statement in the following code fails. The value of captcha_sa is returned undefined. function submitForm(confirmCode, event) { var visitorConfirmation = confirmCode; console.log('visitorConfirmation: ' + visitorConfirmation); if (visitorConfirmation == captcha_sa) { var search_letter_input = $("input#letter_input").val(); if (search_letter_input == "") { // $("#letter_input_error").show().append('<br />'); var inputError = $("#letter_input_error").html(); $(".MissingEntry").css('display', 'block'); $('.CaptchaSuccess').css('display', 'none'); $('.CaptchaError').css('display', 'none'); $('.CaptchaInstruction').css('display', 'none'); $("#letter_input").focus().focusout(function() { $("#letter_input_error").hide(); }); } else { $('.CaptchaSuccess').css('display', 'block'); $('.CaptchaError').css('display', 'none'); $('.CaptchaInstruction').css('display', 'none'); $(".MissingEntry").css('display', 'none'); event.preventDefault(); findAndDisplay_letter(search_letter_input); } $('.CaptchaError').css('display', 'none'); $('.CaptchaInstruction').css('display', 'none'); event.preventDefault(); findAndDisplay_letter(search_letter_input); } else { $('.CaptchaError').css('display', 'block'); $('.CaptchaSuccess').css('display', 'none'); $('.CaptchaInstruction').css('display', 'none'); event.preventDefault(); findAndDisplay_letter(search_letter_input); } } SOURCE: https://www.grammarcaptive.com/_utilities/javascript/search_letter.js Roddy
  16. Yes, it is likely a problem of scope, because I can get it to work, if I generate the variable after the additional script has loaded. I need, however, to have the value already in place and available, before the additional code is run. Is there someplace that I can store it to make it available at any time? Roddy
  17. BACKGROUND: I have a page that, when loaded, creates several values via PHP. These values are assigned to several Javascript variables on the same page. I have verified that the assignment succeeds. When a visitor clicks on the page a visible div on the page is filled with the content of another div on the same page page, and additional javascript and CSS are loaded from another document. I have verified that this latter load does succeed, and that at least one of the functions contained therein is accessible. DILEMMA: Unfortunately, this freshly loaded Javascript is unable to find the values of the Javascript variables to which the PHP values were assigned when the page was initially downloaded. QUESTION ONE: What are the plausible reasons for not being able to find the relevant variables? QUESTION TWO: How do I make them findable? Roddy
  18. iwato

    A Problem of Scope

    Very nice. Have a great weekend! Roddy
  19. iwato

    A Problem of Scope

    DILEMMA: What I would like following function to do is keep iterating until it has satisfied the condition: abs($random_lum - $contrast_lum) > $lum_differential What it does instead is return NULL and stops, when it is unable. function select_color_pair($base, $lum_differential =0.25){ $color_pair = array(); $result = array( 'rgb' => [], 'hex' => '' ); for( $i=0; $i<3; $i++ ){ $rand = mt_rand(0, 255); $result['rgb'][] = $rand; $dechex = dechex($rand); if(strlen($dechex) < 2){ $dechex = '0' . $dechex; } $result['hex'] .= $dechex; } if ($base == true) { $random_lum = COLOR::fromRGB($result['rgb'])->getLuminance(); $contrast_color = COLOR::fromRGB($result['rgb'])->invert(); $contrast_lum = COLOR::fromHex($contrast_color)->getLuminance(); if (abs($random_lum - $contrast_lum) > $lum_differential) { $random_color = COLOR::fromRGB($result['rgb'])->getHex(); return $color_pair = ['text_color' => $random_color, 'bg_color' => $contrast_color]; } else { select_color_pair($base); } } else { $random_lum = COLOR::fromHex($result['hex'])->getLuminance(); $contrast_color = COLOR::fromHex($result['hex'])->invert(); $contrast_lum = COLOR::fromHex($contrast_color)->getLuminance(); if (abs($random_lum - $contrast_lum) > $lum_differential) { return $color_pair = ['text_color' => strtoupper($result['hex']), 'bg_color' => strtoupper($contrast_color)]; } else { select_color_pair($base); } } } Any suggestions? Roddy
  20. Yes, it works! Hooray! Hooray! Roddy
  21. iwato

    A Problem of Scope

    function select_color_pair($lum_differential, $base = true, $type = true) { function random_color($base, %type){ ... Do something with $base and $true } } QUESTION: Is the second appearance of the parameters $base and $type necessary? Roddy
  22. So, if I had written $result = array( 'rgb' => [], 'hex' => '' ); then I would not have had to rewrite the function. Is this correct? Roddy
  23. So, are you saying that $result['rgb'][$col] is being read as NULL[$col]? If so, what happened between PHP 5.3.8 and PHP 7.2 that changed $result['rgb'] from an element of an array to a string? Roddy
  24. BACKGROUND: The following newly created function works splendidly with PHP 5.3.8, but it fails nearly totally in PHP 7.2. Still there is no error message. The FUNCTION: function random_color($base = true, $type = true){ $result = array( 'rgb' => '', 'hex' => '' ); foreach( array('r', 'b', 'g') as $col){ $rand = mt_rand(0, 255); $result['rgb'][$col] = $rand; $dechex = dechex($rand); if(strlen($dechex) < 2){ $dechex = '0' . $dechex; } $result['hex'] .= $dechex; } if ($base == true) { if ($type == true) { return $result['rgb']; } else { return join(",", $result['rgb']); } } else { return strtoupper($result['hex']); } } QUESTION: What must I change to get it to work with PHP 7.2. HINT ONE: The function delivers well when the $base parameter is set to false. Otherwise, it returns only one of the three RGB colors no matter the value of $base or $type. HINT TWO: There is an error message after all. Simply, I was looking in the wrong place. [08-Aug-2019 18:04:40 UTC] PHP Warning: Illegal string offset 'r' in ..../includes/random_color.incl.php on line 15 [08-Aug-2019 18:04:40 UTC] PHP Warning: Illegal string offset 'b' in ..../includes/random_color.incl.php on line 15 [08-Aug-2019 18:04:40 UTC] PHP Warning: Illegal string offset 'g' in ..../includes/random_color.incl.php on line 15 ANSWER: function random_color($base = true, $type = true){ $result = array( 'rgb' => '', 'hex' => '' ); $keys = ['r', 'b', 'g']; foreach( $keys as $key => $value ){ $rand = mt_rand(0, 255); $result['rgb'][$value] = $rand; $dechex = dechex($rand); if(strlen($dechex) < 2){ $dechex = '0' . $dechex; } $result['hex'] .= $dechex; } if ($base == true) { if ($type == true) { return $result['rgb']; } else { return join(",", $result['rgb']); } } else { return strtoupper($result['hex']); } } NEW QUESTION: But why? Roddy
  25. It worked! As is often the case, I am heartily embarrassed. Sometimes I get so lost in the trees that I can no longer see the forest. The new resetForm() function: function resetForm() { $.ajax({ type: "POST", url: './php/captcha_reset.php', data: {dataRequest: 'requestInstance'}, statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(jsonData) { jsonObj = JSON.parse(jsonData); captcha_sa = jsonObj.captcha_ra; $('#captcha_answer').val(''); $('#captcha_question').html(jsonObj.captcha_rq); $('#captcha_success').css('display', 'none'); $('#captcha_error').css('display', 'none'); } }); } Have a great day! Roddy
×
×
  • Create New...