Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About fatkatie

  • Rank
    Advanced Member
  1. I know apache writes a log that contains this information. Does php has a function that can obtain apache's last restart time? xampp, w10 (lastest stuff) Thank you.
  2. fatkatie

    How to insure good form data winds up in the table.

    @#$@#$@! You spend all day on something that has nothing to do with anything. It was a stupid join. mb_check_encoding But, I would like to know if mb_check_encoding() is worth anything. I've relied on binding which has never failed me. Thank you.
  3. fatkatie

    How to insure good form data winds up in the table.

    while ($pending || $row = $sth->fetch(PDO::FETCH_OBJ)) { $pending = false; $hn = $row->houseid; writeData("READ $hn", __FILE__, __LINE__); } There's the loop. houseid starts repeating. I found the record but I don't see anything wrong yet. Newlines? I'm going to rewrite the record with the check and see what that does.
  4. I just started populating a mysql table with data collected from a form posting. I do the dance ... $post_partnumber_source = html_entity_decode(trim(fvs($_POST['nsel_pnsrc'])));where fvs is function fvs($string){$string = filter_var($string, FILTER_SANITIZE_STRING); return $string; } And then I use PDO and binding. Something has happened. Something bad. My PHP $sth->fetch(PDO::FETCH_OBJ) loops are failing. All the records are not being read (some seem to be read twice)... and it happens around the record when form input was starting to be used. It's got to illegal data messing this up. So, my question is, what now? Will mb_check_encoding() solve this or am I missing something very basic. Thank you. mysql Ver 15.1 Distrib 10.1.37-MariaDB, for Win32 (AMD64), Using configuration as supplied by xampp
  5. I have a search function that finds parts. It's a callback that constructs a new form with all items found contained in a table. This form/table is returned and appended to the html using this (within a div element) jQuery('#iddiv_searchresultsarea').empty().append(html); Each of the input text areas, available for updating, has a proper element id. Here's an example row (within a table; within a form): <tr> <td>73T3590</td> <td>Hinge, Blum Plus</td> <td><input type="text" id="idin_loc_73T3590" value="A206" maxlength="20" size="4"></td> <td><input type="text" id="idin_qty_73T3590" value="1" maxlength="20" size="4"></td> <td> <button class="btn btn-primary" type="button" id="idbut_73T3590" name="nbut_73T3590" value="UPDATE" onclick="updateStock('73T3590')"> </button></td> <td>Blum Hinge Plus Inserta Full O/L 110 Deg</td> <td>no image</td> </tr> For some reason, jQuery does not see any of this. javascript getElementById() works just fine. Here is a simple snip of the problem: function updateStock(pn) { var qty_value = document.getElementById('idin_qty_263.16.705').value; alert("qty value " + qty_value); // ok jQuery(document).ready(function() { var stock_qty = jQuery('#idin_qty_263.16.705').val(); alert("stock qty " + stock_qty ); // undefined . . . Do I have to do something else after the append to 'sync' up the page? Or is this a scope issue that I won't figure out until next week. Thanks.
  6. I had no idea! Scope, closure, hoisting ... I really don't know this stuff. I did get the function parameter pn into the jQuery part by simply assigning it as in (ff65): function updateStock(pn) { alert("here is the pn: " + pn); var mypn = pn; jQuery(document).ready(function() { alert("I want to see pn here: " + mypn); }); } Lots of reading and re-reading to do. Thanks
  7. The onclick event is set to call a javascript function. I need to use jQuery within that javascript function. Is that possible? Thank you. function updateStock(pn) { alert("here is the pn: " + pn); jQuery(document).ready(function() { alert("I want to see pn here: " + pn); }); }
  8. I have to move to W10 from my beloved W7 box. I found that most software I used on W7 is ported for W10 but I didn't find a free mysql Toad for W10. I really loved that thing. The web based 'workbench' is so clunky. Is there a free toad out there to work with mysql? Please suggest alternatives if you have something you like. (using xampp mysql) Thank you.
  9. It's probably not defined. Test for it first.
  10. fatkatie

    php optimization; 1 or 2 if's

    I just replaced the single line if using the second index array with a single value. It's still slower. $val = 22; while($count_samples--) { //if ($a_true_and_false[$count_samples] && $a_random_int_stuff[$count_samples]) { if ($a_true_and_false[$count_samples] && $val) { $hit_1_count++; } } Done. Out.
  11. fatkatie

    php optimization; 1 or 2 if's

    Finally got around to this question of mine. Using the original parameters of mostly false I ran the following code. There may be many reasons why this test is not valid. I have no advanced knowledge concerning such profiling. I tried to keep the paths equal and to wash out any time glitch issues. It was found that the nested if construct was faster - every time - than the single line short circuit. It's probably due (I'd guess) to the need to access/build the second ALWAYS_CHANGING variable in the if construct. Env: PHP 5.6+ on Win7Pro64, executed as php script in command window. <?php $micro_time_param = true; $number_of_samples = 100000; $frequency_false = 99; $a_true_and_false = array_fill(0, $number_of_samples, false); $number_of_trues = $number_of_samples - intval($number_of_samples * $frequency_false / 100); $a_random_int_stuff = array(); // always true for ($idx = 0; $idx < $number_of_samples; $idx++) { $a_random_int_stuff[$idx] = rand(1, $number_of_samples); } // Scatter the true hits within the array $count_trues = $number_of_trues; while($count_trues--) { $r_index = rand(0, $number_of_samples - 1); $a_true_and_false[$r_index] = true; } $hit_1_count = 0; $hit_2_count = 0; $hit_1_sum = 0.0; $hit_2_sum = 0.0; $hit_1_start = ''; $hit_1_end = ''; $hit_2_start = ''; $hit_2_end = ''; $wash_loop = 1000; $dec_something = $wash_loop; while ($wash_loop--) { // LOOP 1 $count_samples = $number_of_samples; $hit_1_start = microtime($micro_time_param); while($count_samples--) { if ($a_true_and_false[$count_samples] && $a_random_int_stuff[$count_samples]) { $hit_1_count++; } } $hit_1_end = microtime($micro_time_param); $hit_1_sum += (float)($hit_1_end - $hit_1_start); // LOOP 2 $dec_something--; $count_samples = $number_of_samples; $hit_2_start = microtime($micro_time_param); while($count_samples--) { if ($a_true_and_false[$count_samples]) { if ($a_random_int_stuff[$count_samples]) { $hit_2_count++; } } } $hit_2_end = microtime($micro_time_param); $hit_2_sum += (float)($hit_2_end - $hit_2_start); } echo "Time hit 1 $hit_1_sum , hit count $hit_1_count\n"; echo "Time hit 2 $hit_2_sum , hit count $hit_2_count\n";
  12. fatkatie

    php optimization; 1 or 2 if's

    barand - I think what I want is getrusage - wall clock time v/s cpu time. https://stackoverflow.com/questions/535020/tracking-the-script-execution-time-in-php
  13. fatkatie

    301 Redirect Regex

    I'm not trying to undermine gizmola here. It's a fine answer. But since the topic of recognizing a name showed up, here's an interesting post: in_array vs strpos for performance in php. It concerns the fastest way to find that needle (within some constraints). https://stackoverflow.com/questions/21070691/in-array-vs-strpos-for-performance-in-php#21070786 If posting links are not welcome here, administrator, feel free to nuke the post. Thanks.
  14. fatkatie

    php optimization; 1 or 2 if's

    barand - yah, I think you're correct. Timing the loop may be the best way. There are just too many things going on. I imagine the second assignment might change according to optimization rules - of which I have no clue. I'll try a few later. My bet? These will run at different speeds. We'll see. But ... Will microtime return the time spent actually executing? What if there is a process swap? For others, I should have stated the changing value was an integer. I've always wondered about the word 'redundant' as it relates to verbose. (Does RTFM mean what I think it does? ) Thanks again.
  15. This is simple curiosity. I'd like to know if someone really knows the answer. I've always been suspicious of performance testing with loops. I have a loop in php. Within that loop I act based on two values, let's call them MOSTLY_FALSE and ALWAYS_CHANGING. Given MOSTLY_FALSE is seldom true, is the second "double" IF faster than the 'single', or will the short-circuit take care of it? I sometimes code with the double form just to let people know that truth is exceptional. Thanks. (Just curious.) if ( MOSTLY_FALSE == true && ALWAYS_CHANGING == 1) { // do this exceptional thing } if ( MOSTLY_FALSE == true) { // access ALWAYS_CHANGING for the first time (is a field returned in sql query if (ALWAYS_CHANGING == 1) { // do this exceptional thing } }

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.