Jump to content

Barand

Moderators
  • Posts

    24,606
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. That's because you keep writing to the same image template. Recreate each time in the loop and destroy at the end to release the memory. $sql = mysqli_query($con, "SELECT id, empname FROM employees"); header('Content-type: image/png'); $image = imagecreatefrompng('id-template.png'); $color = imagecolorallocate($image, 0, 0, 0); imagepng($image); while($rs = mysqli_fetch_assoc($sql)){ $image = imagecreatefrompng('id-template.png'); $color = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 13, 0, 60,117, $color, $font, $rs['empname']); //employee name location of the template $save = "id/".strtolower($rs['id']).".png"; imagepng($image, $save, 9, PNG_NO_FILTER); imagedestroy($image) } PS Wouln't it make more sense to have a different image for each employee - or do you only employ clones?
  2. Then $_POST['nfield'] is not an array as exepected. You need to check why. What is the form markup code where it originates?
  3. My question... His answer... Apparently he thinks error messages are just unnecessary clutter to be ignored.
  4. Apparently they were for you too when you woke up... What changed? Did you then read the error messages?
  5. Perhaps reading the error messages might give you a clue, even if the errors are glaringly obvious. At least you are able to read them; an opportunity not given to anyone else.
  6. perhaps ? echo str_replace("\\", "\\u{", "\\f192"); //--> \u{f192
  7. Change it. E_ALL and E_NOTICE = E_NOTICE | E_ALL | 111111111111111 | | E_NOTICE | 1000 | | E_ALL & E_NOTICE | 1000 | If you want to switch off notices you need E_ALL and not E_NOTICE | E_ALL &~ E_NOTICE | 111111111110111 | (By the time you get to production any e_notices should've been eliminated)
  8. -> +-----------------------+---------------+--------------+ | php.ini file setting | development | production | | | server | server | +-----------------------+---------------+--------------+ | error_reporting | E_ALL | E_ALL | | display_errors | ON | OFF | | log_errors | OFF | ON | +-----------------------+---------------+--------------+
  9. Barand

    Howdy!

    Welcome
  10. Then remove it. I put it there to make it easy for me to check that the data differences were correct. When you come across an example of how to do something then you have to adapt that example to your situation and needs - not blindly copy, paste and pray.
  11. All you needed to do was substitute your connection "$conn" for my "$pdo". My coding in this instance is mysqli/pdo neutral. Remove the catch{} stuff.
  12. Perhaps he hasn't realized yet that ignoring your commandments can cause your wrath to descend on him in the form of seven deadly plagues.
  13. He is saying that to output a "%" in a format string you need to have "%%". printf("<img src='images/%s' style='width: 100%%' />" , basename($filename));
  14. Because you don't have database connection in a variable $pdo. That depends on what you do with them.
  15. Or do it the easy way code $res = $pdo->query("SELECT created_at FROM test_b ORDER BY created_at DESC "); $today = new DateTime('now'); foreach ($res as $row) { $dt = new DateTime($row['created_at']); $diff = $dt->diff($today)->format("%y years -- %m months -- %d days"); echo "{$row['created_at']} | $diff <br>"; } output 2020-10-15 00:00:00 | 1 years -- 9 months -- 22 days 2020-09-06 00:00:00 | 1 years -- 11 months -- 0 days 2019-04-09 00:00:00 | 3 years -- 3 months -- 28 days 2019-03-08 00:00:00 | 3 years -- 4 months -- 29 days 2018-06-06 00:00:00 | 4 years -- 2 months -- 0 days 2018-06-04 00:00:00 | 4 years -- 2 months -- 2 days 2018-05-27 00:00:00 | 4 years -- 2 months -- 10 days 2018-05-15 00:00:00 | 4 years -- 2 months -- 22 days 2018-02-03 00:00:00 | 4 years -- 6 months -- 3 days 2018-01-05 00:00:00 | 4 years -- 7 months -- 1 days
  16. I am curious - what was the original problem for which you have the above as a solution?
  17. Did placing that new line in the function create the file?
  18. Try outputting to a file then. (The file "rates_array_content.txt" should be created in the same folder as your script) function shipping_methods_based_on_wholesale_customer( $rates, $package ){ file_put_contents('rates_array_content.txt', print_r($rates, 1)); if( ! get_current_user_id() ) { unset($rates['flat_rate:10'], $rates['flat_rate:7']); // To be removed for NON Wholesale users } else { unset($rates['flat_rate:13'], $rates['flat_rate:15']); // To be removed for Wholesale users } return $rates; }
  19. I was hoping it would be sent to your screen
  20. It's your $rates array - the one you are using in the function that's being discussed all through this topic. Put the code I gave inside the function and post the out put to us. function shipping_methods_based_on_wholesale_customer( $rates, $package ){ echo '<pre>' . print_r($rates, 1) . '</pre>'; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< if( ! get_current_user_id() ) { unset($rates['flat_rate:10'], $rates['flat_rate:7']); // To be removed for NON Wholesale users } else { unset($rates['flat_rate:13'], $rates['flat_rate:15']); // To be removed for Wholesale users } return $rates; }
  21. With the code I've given you to output the $rates array
  22. As requested some time ago... ...and still waiting.
  23. Something like this, maybe? function shipping_methods_based_on_wholesale_customer( $rates, $package ){ if( ! get_current_user_id() ) { unset($rates['flat_rate:10'], $rates['flat_rate:7']); // To be removed for NON Wholesale users } else { unset($rates['flat_rate:13'], $rates['flat_rate:15']); // To be removed for Wholesale users } return $rates; }
×
×
  • 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.