-
Posts
24,606 -
Joined
-
Last visited
-
Days Won
831
Everything posted by Barand
-
How to generate multiple image from single template using php
Barand replied to neilfurry's topic in PHP Coding Help
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? -
Warning tells me that Count () needs to be an array
Barand replied to nextgen's topic in PHP Coding Help
Then $_POST['nfield'] is not an array as exepected. You need to check why. What is the form markup code where it originates? -
My question... His answer... Apparently he thinks error messages are just unnecessary clutter to be ignored.
-
Apparently they were for you too when you woke up... What changed? Did you then read the error messages?
-
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.
-
perhaps ? echo str_replace("\\", "\\u{", "\\f192"); //--> \u{f192
-
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)
-
-> +-----------------------+---------------+--------------+ | php.ini file setting | development | production | | | server | server | +-----------------------+---------------+--------------+ | error_reporting | E_ALL | E_ALL | | display_errors | ON | OFF | | log_errors | OFF | ON | +-----------------------+---------------+--------------+
-
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.
-
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.
-
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.
-
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));
-
Because you don't have database connection in a variable $pdo. That depends on what you do with them.
-
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
-
How can I pass class object to onclick function ?
Barand replied to eaglehopes's topic in Javascript Help
I am curious - what was the original problem for which you have the above as a solution? -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
-
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
Did placing that new line in the function create the file? -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
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; } -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
I was hoping it would be sent to your screen -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
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; } -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
With the code I've given you to output the $rates array -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
As requested some time ago... ...and still waiting. -
PHP isn't targeting guest customers in Woocommerce
Barand replied to martini0's topic in PHP Coding Help
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; }