Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 12/29/2019 in all areas

  1. 3 points
    Don't use $GLOBALS. Forget it exists. There is never a good reason to use it. Pretend you never saw it.
  2. 2 points
    A few notes about text bounding boxes which, I hope, will help in precise placement of your text. Suppose I have the text string "The lazy fox" which I want to display using 150pt Vivaldi . My image is 4896 x 3672 and I want the text placed at the bottom right but 250 pixels from the edges of the image. $box = imagettfbbox(150,0,'c:/windows/fonts/vivaldii.ttf','The lazy fox'); gives this array of coordinates of the four corners $box = Array ( [0] => 23 [1] => 55 [2] => 871 [3] => 55 [4] => 871 [5] => -140 [6] => 23 [7] => -140 ) You may wonder why it can't just give a rectangle from (0,0) to (width, height) to make sizing simple, but there is extra information to be extracted from the array Text width = (871 - 23) = 848 Text height = 55 - (-140) = 195 The baseline will be 140px from the top The text is offset 23 px to the right. My text, therefore, will be in a rectangle 848 x 195 positioned 250 px from right and bottom edges. The top left x coord of the rectangle will be (4896 - 250 - 848) = 3798 and top left y coord will be (3672 - 250 - 195) = 3227. However, to land the text precisely into this area we position it on the baseline and at the required x offset, ie (3798 - 23 , 3227 + 140) = (3775, 3367). I use a simple custom function to assist with this process function metrics($font, $fsize, $str) { $box = imagettfbbox($fsize, 0, $font, $str); $ht = abs($box[5] - $box[1]); $wd = abs($box[4] - $box[0]); $base = -$box[5]; $tx = -$box[0]; return [ 'width' => $wd, 'height' => $ht, 'ascent' => $base, 'offsetx' => $tx ]; } $box = metrics ('c:/windows/fonts/vivaldii.ttf', 150, 'The lazy fox'); $box = Array ( [width] => 848 [height] => 195 [ascent] => 140 [offsetx] => -23 )
  3. 2 points
    For example, https://www.php.net/manual/en/datetime.createfromformat.php https://www.php.net/manual/en/datetime.format.php
  4. 1 point
    You obviously don't know any php and furthermore are not willing to open up a book and look anything up. The trim function (mentioned above) is one that removes leading and trailing spaces from a string. That is all. It has nothing to do with a loop or with output. Why are you into something this deep if you don't know anything about php or programming? As a professional programmer I find it ridiculous when people with no knowledge think they can just jump into it and hope someone can hold their hand for the next 2 months teaching them what they should already have tried to learn for themselves. Have fun. It's a learning process that can possibly give you a new set of knowledge that you may find invaluable. But - it takes work. Good bye
  5. 1 point
    Make ticket_number an auto_increment column CREATE TABLE raffle ( name VARCHAR(50) ticket_number INT NOT NULL auto_increment primary key ); INSERT INTO raffle (name) VALUES ('Curly'), ('Curly'), ('Curly'), ('Larry'), ('Larry'), ('Larry'), ('Larry'), ('Larry'), ('Mo'), ('Mo'), ('Mo'), ('Mo'), ('Mo'), ('Mo'); SELECT name, ticket_number FROM raffle; +-------+---------------+ | name | ticket_number | +-------+---------------+ | Curly | 1 | | Curly | 2 | | Curly | 3 | | Larry | 4 | | Larry | 5 | | Larry | 6 | | Larry | 7 | | Larry | 8 | | Mo | 9 | | Mo | 10 | | Mo | 11 | | Mo | 12 | | Mo | 13 | | Mo | 14 | +-------+---------------+
  6. 1 point
    The "check" is actually the result of the animation. Look at the animation itself for where you can change the color.
  7. 1 point
    Note that "$get_the_title()" is not the same as "get_the_title()".
  8. 1 point
    Alternatively, you could just update the line that defines $site_title. That way you're not calling get_the_title() multiple times. Plus, the value should be escaped for inclusion in an HTML attribute. $site_title = esc_attr( get_the_title() ); As for the following, WordPress' the_title() function echos the value be default. I forget what happens when you try to echo something that has already been echoed in WordPress, but that probably lead to the issues you were having.
  9. 1 point
    The braces are required when embedding complex variable names (an array element) inside other things. Without them you would get a syntax error. You could use concatenation (dots) to avoid this but with the braces you can skip the concatenating and just compose one contiguous string here. The thing I wanted you to note was the quotes on the array indices. A Key thing!
  10. 1 point
    echo "<a href='{$row['link']}' target='_blank'>&diams;&nbsp;&nbsp; {$row['title']}</a><br>";
  11. 1 point
    Note that is for the fixed-width fonts that GD supports out of the box. With TTF fonts, character widths vary so calculating the right offset is a bit harder.
  12. 1 point
    @gizmola, Thanks for the thoughts. All of this is definitely a journey, because as I sketch things out (and talk to people) I learn new things and that can change my design. Dealing with the unknown and not knowing how to design things until you successfully design thing is what makes all of this a challenge! I'll take what you and others have said above and try to come up with a design that is flexible, scalable, and that helps me retain customers and make $$$. Thanks.
  13. 1 point
    Hey Saranac, You seem to be conflating a "transaction" which is a database specific term, with a single page application (SPA) or combined form. What you do serverside with that form is up to you. Ease of use, credit card/payment processing and the dangers and cost of fraud are a complicated witches brew of risk/reward calculations. First of all, I don't know what you know or don't know about payment processing, but just because you got a cc authorization doesn't mean you will ever get paid. Worse yet, you could get a chargeback, and if you have enough chargebacks, you might end up having your merchant account closed. Again, maybe you know this or you don't. I don't know what your content is, or whether or not there will be a high amount of fraudulent activity, but every online business has some. So, as to transactions, and to "best practices" for selling digital goods or memberships, these topics are unrelated. At its simplest, a Member in your system, as you stated yourself, is not equivalent to a membership package. Membership packages also have one or more related "entitlements". So no doubt you have a package described in the database somewhere, and when someone successfully subscribes to a package for a year, one would expect a database structure like this: package ---< member_package >-- member where member_package is a table that stores "member_id", "package_id", "from_date", "to_date". What are strategies for dealing with the system. Well one, would be to have the culmination of a successful payment process be the setting of the "from_date" and "to_date". Another strategy might be to also utilize a "status" column with mutually exclusive states like: pending payment active suspended for fraud expired In that case you create the row, and can then use "active" status to drive access (along with from/to). Regardless of the form you use, there is no benefit to wrapping the creation of a member row with the transaction processing. If a member fills out all their details and has payment processing issues, it behooves you to create the membership row and put them into "pending payment" state. This way you can see how many people had issues with payment processing at any particular period of time. That way you can reach out to people who for whatever reason drop out of the payment process. You have contact info to market to them, or entice them with discounts. And there is always the situation where your payment processor was rejecting everything and these are customers you have 100% lost forever without some record that they tried to subscribe. DB transactions are important from a mechanical standpoint and I highly recommend using them, but you can have multiple transactions in your processing ie (membership account + address) THEN (payment processing & activation) and these can be handled separately in your code. Once you have some identity information, it's valuable to continue to carry this along in your session rather than stubbornly demand that the behavior of your system should conform to your ideal "happy path" scenario where a user puts in all their identity information for their membership perfectly, and at the same time gets the payment information entered perfectly and receives authorization. A "member" row, should be decoupled from membership (which you already stated you understand and agree with) which should be decoupled from subscription(s) which should be decoupled from payment processing details.
  14. 1 point
    Good luck to you on that Jayfromsandiego. Try to post on Stackoverflow, or any of our myriad competitors. I certainly hope you will, if only so that you will find after the time it takes for you to register on each community and (re)post your "question" then wait for a response that may or may not ever come, only to find your question closed or ignored, or with a similar response to those you got here. This forum has a longstanding tradition of acceptance and hand holding that goes way beyond vast majority of programming forums that exist. As your question boils down to: "Here's what I want, code it for me?" don't be surprised when you get responses like ginerjm in even more blunt fashion. Meanwhile, NotSunfighter decided to take you up on your challenge and coded you up a solution. And just to be clear, noone (perhaps with the exception of NotSunfighter, after having spent valuable time trying to help you) cares whether you quit this forum. We are all volunteers. ginerjm may have been blunt, but he's right. We can all code. The vast majority of the people who answer questions like yours are professional developers. We are here to teach and share, and sometimes to simply tell someone the truth. The best I can hope for you at this moment is that you take a good hard look in the mirror at your own attitudes and approaches, and as the old saying goes "Don't cut off your nose to spite your face."
  15. 1 point
    If this is true, then why is there a problem? Make a users account, process their payment, and move on. If the payment fails just don't grant them any entitlement. Just because you put everything on one page for the user to enter their information doesn't mean you have to process it as an all-or-nothing thing. You can still process it as separate actions and handle any problems appropriately. For example, if the payment fails keep the account information and just send them to a payment form (similar to what you'd do for a member who's subscription is expired). You need a way for someone to be registered without an active subscription. Whether or not that user can do anything is up to you. Allowing a little bit of bonus abilities for simply registering is a common and good way to get people to hop on board. Registered users are easier to track and manage than a bunch of anonymous people. If you ever want to do something like sell ads or potentially the website as a whole having statistics about usage will be very beneficial and registered users can give you some good statistics.
  16. 1 point
    Alternative model which allows multiple siblings jdev_nroll; jdev_sibling; +----+--------+---------+-------+-----------+------------+ +------------+----------+ | id | sname | ctclass | shift | ctstudent | dob | | sibling_id | elder_id | +----+--------+---------+-------+-----------+------------+ +------------+----------+ | 1 | Curly | 1 | 0 | N | 2007-01-20 | | 2 | 1 | | 2 | Larry | 1 | 0 | Y | 2010-12-21 | | 3 | 1 | | 3 | Mo | 1 | 0 | Y | 2011-02-22 | | 3 | 2 | | 4 | Peter | 1 | 0 | N | 2009-01-03 | | 4 | 5 | | 5 | Paul | 1 | 0 | N | 2006-12-21 | | 9 | 8 | | 6 | Mary | 1 | 0 | Y | 2010-09-20 | | 9 | 10 | | 7 | Jane | 1 | 0 | N | 2008-03-08 | | 10 | 8 | | 8 | John | 1 | 0 | N | 2006-10-04 | +------------+----------+ | 9 | George | 1 | 0 | Y | 2010-10-26 | | 10 | Ringo | 1 | 0 | Y | 2009-11-15 | +----+--------+---------+-------+-----------+------------+ SELECT a.id as sibling_id , a.sname as sibling_name , TIMESTAMPDIFF(YEAR,a.dob,curdate()) as sibling_age , a.ctclass as class , b.id as elder_id , b.sname as elder_name , TIMESTAMPDIFF(YEAR,b.dob,curdate()) as elder_age , b.ctstudent as elder_ctstudent FROM jdev_nroll a JOIN jdev_sibling s ON a.id = s.sibling_id JOIN jdev_nroll b ON s.elder_id = b.id WHERE a.ctstudent = 'Y' ORDER BY a.id +------------+--------------+-------------+-------+----------+------------+-----------+-----------------+ | sibling_id | sibling_name | sibling_age | class | elder_id | elder_name | elder_age | elder_ctstudent | +------------+--------------+-------------+-------+----------+------------+-----------+-----------------+ | 2 | Larry | 9 | 1 | 1 | Curly | 13 | N | | 3 | Mo | 8 | 1 | 1 | Curly | 13 | N | | 3 | Mo | 8 | 1 | 2 | Larry | 9 | Y | | 9 | George | 9 | 1 | 8 | John | 13 | N | | 9 | George | 9 | 1 | 10 | Ringo | 10 | Y | | 10 | Ringo | 10 | 1 | 8 | John | 13 | N | +------------+--------------+-------------+-------+----------+------------+-----------+-----------------+
  17. 1 point
    And if a child has a brother and a sister (or two or more of any gender)? [edit] There's this method, but it doesn't show explicitly that there is also a relationship between Curly and Mo too. SELECT * FROM jdev_nroll; +----+--------+---------+-------+-----------+---------+-----------+ | id | sname | ctclass | shift | siblingof | elderof | ctstudent | +----+--------+---------+-------+-----------+---------+-----------+ | 1 | Curly | 1 | 0 | 2 | | Y | | 2 | Larry | 1 | 0 | 3 | 1 | N | | 3 | Mo | 1 | 0 | | 2 | Y | | 4 | Peter | 1 | 0 | | 5 | N | | 5 | Paul | 1 | 0 | 4 | | Y | | 6 | Mary | 1 | 0 | | | N | | 7 | Jane | 1 | 0 | | | Y | | 8 | John | 1 | 0 | 9 | | N | | 9 | George | 1 | 0 | 10 | 8 | Y | | 10 | Ringo | 1 | 0 | | 9 | N | +----+--------+---------+-------+-----------+---------+-----------+ SELECT a.id , a.sname , a.ctclass , a.shift , a.ctstudent , b.id as bid , b.sname as bname , b.ctstudent as bstudent FROM jdev_nroll a JOIN jdev_nroll b ON a.siblingof = b.id; +----+--------+---------+-------+-----------+----+--------+-----------+ | id | sname | ctclass | shift | ctstudent |bid | bname | bstudent | +----+--------+---------+-------+-----------+----+--------+-----------+ | 1 | Curly | 1 | 0 | Y | 2 | Larry | N | | 2 | Larry | 1 | 0 | N | 3 | Mo | Y | | 5 | Paul | 1 | 0 | Y | 4 | Peter | N | | 8 | John | 1 | 0 | N | 9 | George | Y | | 9 | George | 1 | 0 | Y | 10 | Ringo | N | +----+--------+---------+-------+-----------+----+--------+-----------+
  18. 1 point
    I'm not concerned about it because it doesn't have to be. Like you said, you feel like it has to be a certain way. I'm telling you that no, it does not. It's something separate from this to consider doing, but one that I recommend. But if you do it then you'll simplify some of this problem. No, what you're doing is allow anonymous access. I'm saying allow authenticated but non-premium access. Give like 20% access for anonymous users to get people to the site. Allow 30-40% access, plus maybe a couple features, for authenticated users to get people to sign up. Allow 100% access for people who pay money. This here is some fairly basic economics about funnels. Let people ease into your site until they're comfortable with the idea of paying money; making it a single step of "30% access and you have to pay to do anything more" is a cut-off that is going to lose you customers. Allow unpaid access. Give people who are interested in your site another step they can take that doesn't require them to pull out their wallets. Because you're fixated on the whole "omg it's all at the same time" thing that I keep telling you it is, in fact, not the case. No. It's dumb, but it's not a sin. I don't see how what you're describing now is different from what you were talking about originally. Before you wanted to do everything "at once". Now you want to do everything "at once". It's the same thing, just different words. 10 concurrent users is nothing. It's unlikely to happen, of course, but when you have everything "at once" taking a long time then you have to care more. For varying definitions of the word "slim". Congratulations. But you're describing stuff that everybody does differently. And they do it differently for a good reason: because it works better. You aren't anywhere near a point where you can run A/B testing to discover for yourself what works better and what does not, so maybe set aside your own designs and take a look at what other websites do. Because they have done the testing.
  19. 1 point
    Depending on your business needs, sure: you could do all of those at the same time. But you're approaching this like it's all-or-nothing. It isn't. You can create the user regardless of the transaction. You can record the order regardless of whether the payment goes through. Don't treat it like it's all one big operation that you have to rollback/cancel if any one step fails - make each part work in its own right, just like if the user was in control of each step.
  20. 1 point
    https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_result-file
  21. 1 point
    Why in the world would you store it that way in the first place? Thought it may work now, down the road who knows what kind of problems this will present. Now is the time to fix the schema so it makes sense.
  22. 1 point
    I've not used any of the listed options. The couple API's I've worked on have just used Symfony since that's what I typically use for other applications. It's worked fine for me for the most part. There are various bundles dedicated to implementing REST API's that may be useful (ie, FOSRestBundle).
  23. 1 point
    I know it sounds like a fun project to emulate something that already exists. But - just exactly why do you think it necessary? There is already a $_SESSION array (RTFM) and the ability to make specific local vars global for your entire script (see 'global') . So what design of yours is going to need your own new version of this? Besides - good programming practice does not include making everything globally available.
  24. 1 point
    You can't just copy code and necessarily expect it to work. You need to understand the code presented and then implement your own.
  25. 1 point
    most likely, either your actual database name contains some non-printing/white-space character(s) or the Config::get() method, which you haven't posted the code for, is adding some non-printing/white-space character(s) to the value (i'm betting either a new-line or a <br> tag.) this code is just adding an unnecessary, pointless layer. it has no useful error handling, is using emulated prepared queries (the default), cannot be used with a LIMIT x term in a query, and can't be used with more than one connection or a different database type. if you want to do something useful for a database class, extend the PDO class and add a general prepared/non-prepared query method that will use a prepared query if there are input parameters and will use a non-prepared query if there are not. when you make the database connection, you should set the character set to match your database tables, set the error mode to exceptions, set emulated prepared queries to false, and set the default fetch mode to assoc (assoc works best when dynamically processing fetched data.)
  26. 1 point
    IMHO it's easier just to do both inserts in the same loop as you always want one of each. ////////////////////////////////////// // menu item and connection insert // ////////////////////////////////////// $ins_i = $conn->prepare(' INSERT INTO ssm_menu_items (menu_item_name) VALUES (?); '); $ins_c = $conn->prepare(' INSERT INTO ssm_menu_connection (menu_id, menu_item_id) VALUES (?,?) '); $ins_i->bind_param('s',$nmItem); $ins_c->bind_param('ii', $menuInsId, $menuItmInsId); foreach ($_POST['newMenuItem'] as $nmItem) { $ins_i->execute(); $menuItmInsId = $stmt->insert_id; $ins_c->execute(); }
  27. 1 point
    FYI, this can be (and should be) handled entirely with CSS using nth-child(), not(), and first-child.
  28. 1 point
    i'm going with the code never copies the (unnecessary) $cart_items variable back to the session variable, so the code starts over each time it gets executed. just use $_SESSION["cart_items"] everywhere and forget about the $cart_items variable.
  29. 1 point
    Your misleading choice of variables names no doubt contributed to the problem. There are other things could be improved too Use prepared queries instead of putting variables directly into the sql query strings. (I would also recommend PDO in preference to mysqli) use css classes instead of repetitive inline style definitions you are using deprecated html markup code (eg <tr bgcolor = "#cccccc">) you use a lot of unnecessary concatenation when building strings - a common source of errors.
  30. 1 point
    In your pagination loop you set all the links to the same page number! Should be $data = array( 'page' => $current_page, <-- CHANGED 'country' => $cleaned_current_page_country );
  31. 1 point
    session_start will automatically determine if your starting a new session or resuming one that already exists, but this is not what your error is referring to. The error you're seeing relates to calling session_start multiple times within the same request. The function is only intended to be called once at the start of your request, which is not the same as at the start of every *.php file you have. If you want to have your separate pages that people request and not re-design your application to use a common front-end script or some framework then what you should do is have a common include file that handles your session (and other stuff as needed) and include that in each of your main entry pages using require_once. So your entry points should be coded something like: <?php require_once './includes/common.php'; //whatever else your script does And your common include would just be <?php session_start(); //whatever other common code you want This common include could contain things like your session management code, database connection code, function definitions, etc. Note: there's also a php.ini setting called session.auto_start. If you've enabled that then you don't need to manually call session_start().
  32. 1 point
    I have just noticed you don't use the $page_url in those pagination links. It looks like you intended to but then just used the query string $the_query = http_build_query($data); $page_url .= '?' . $the_query; echo '<li><a href=" '.$the_query.' ">'.$current_page.'</a></li> '; As you go to the same page that should be sufficient but I think you will need the preceding "?" Try $the_query = http_build_query($data); $the_query = '?' . $the_query; echo "<li><a href=\"$the_query\">$current_page</a></li>";
  33. 1 point
    the most immediate problem is you are not using the correct $_POST field and table column in the WHERE clause in the SELECT query (edit: i realized while writing this that the SELECT query you have shown is part of the update process, to retrieve a specific row of data to populate the form fields with, not part of a name search.) if you are entering the name (or partial name) of a game to search for, wouldn't you be searching the table column holding the game's name? why are you trying to match the id column? next, don't write code like this. there's a bunch of problems that have resulted in a wall of code that's both insecure and has created a 'cannot see the forest for the trees' problem (which is perhaps why you are using the wrong field/column in the WHERE clause.) a laundry list of issues - don't create a bunch of discrete variables for each different form you write code for. this is just a waste of typing time. instead, operated on the form data as a set, by keeping the data as an array, and operating on the elements in the array. by using exceptions for database statement errors, any connection, query, prepare, and execute error will transfer control to the exception handler. therefore, any discrete error handling logic in your code won't ever be executed and should be removed. related to #2, the only exception handling try/catch block you should have in your code are for those errors that are recoverable, that your code can do something about, such as dealing with the inserting/updating of duplicate or out of range user submitted data. all other database statement errors are non-recoverable and there's no good reason for your code to catch these exceptions. just let php catch and handle these exceptions. by using exceptions for errors and letting php catch them, php will use its error related settings to control what happens with the actual error information (database statement errors will 'automatically' get displayed or logged the same as php errors.) 'function getPosts()' - don't do this. you want code to be easy to write and debug and be readable by everyone. by intentionally using numerical indexes, you have made more work while writing this code and made more work for anyone trying to read/maintain the code. also, once you write and test the code for a function, you should not find yourself regularly editing the code. functions should not contain application specific code that you must change each time you do something new. external data can be anything and cannot be trusted. you must validate all external data before using it. you should use a prepared query when supplying external/unknown data to the sql query statement. items #6 and #7 will help avoid the current error, because you would not attempt to run a query if an expected input is empty and a numerical input that can be empty/null won't produce a query error. a name or partial name search can match more than one row (the same game name for more than one platform.) you would loop over the result from such a query and display as many rows of data that the query matched. to update/delete the data for a specific row, you would produce an edit link and a delete form for each row that is displayed. the edit link would contain the id of the row. when you click the edit link, the code would query for an fetch the data matching that row and populate the form field values. the current SELECT query seems to be for this part of the process, not for a name search. you need one more SELECT query.
  34. 1 point
    One more attempt. Here's a script which puts the hints I gave you into practice. As you can see, it splits the ordered items into separate order depending on the SKU group SAMPLE: Code (read, understand what's going on and learn. Refer to php.net manual if you don't know what something does.) (Not an elseif()..elseif() to be found!) <?php const HOST = 'localhost'; # const USERNAME = '????'; # const PASSWORD = '????'; # const DATABASE = '????'; # These lines would # function pdoConnect($dbname=DATABASE) # normally be in { # $db = new PDO("mysql:host=".HOST.";dbname=$dbname;charset=utf8",USERNAME,PASSWORD); # an included file $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); # $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); # $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); # return $db; # } # $pdo = pdoConnect(); // // CREATE TEST DATA USED BY THIS EXAMPLE // $pdo->exec("CREATE TABLE IF NOT EXISTS aveeva ( id int not null auto_increment primary key, order_no int, sku int, product varchar(50), qty int ) "); $pdo->exec("REPLACE INTO aveeva (id, order_no, sku, product, qty) VALUES (1,1020345, 12345, 'Pair of left-footed socks', 2), (2,1020345, 35547, 'Square Hula hoop', 1), (3,1020345, 12346, 'Pair of right-footed socks', 2), (4,1020345, 62347, 'Pair of three-legged tights', 5), (5,1020345, 45501, 'String vest', 1), (6,1020345, 45501, 'Thermal long johns (red)', 2), (7,1020345, 22105, 'Staffordshire pot dog', 2), (8,1020345, 38962, '250 Kg dumbell set', 1), (9,1020345, 23176, 'Ming vase', 1), (10,1020345, 23194, 'Porcelain elephant', 1), (11,1020345, 38547, '0.5 metre yoga mat', 1) "); // DUMMY CLASS TO PROVIDE THE METHODS YOU USED class Magee { private $fromName; private $body; private $subject; private $type; private $sendTo; public function __construct() { } public function setFromName($str) { $this->fromName = $str; } public function setBody($str) { $this->body = $str; } public function setSubject($str) { $this->subject = $str; } public function setType($str) { $this->type = $str; } public function setToEmail($str) { $this->sendTo = $str; } public function send() { // // Instead of sending emails // we just build content // for demonstration output // $out = "<fieldset><legend>TO: {$this->sendTo}</legend> <label>From</label>{$this->fromName}<br> <label>Subject</label>{$this->subject}<br> {$this->body}<br> "; $out .= "</fieldset>"; return $out; } } #Magee // define email addresses for the sku groups const DEFAULT_ADDY = 'other@gmail.com'; $addys = [ 2 => 'abc@gmail.com', 3 => 'xyz@gmail.com', 4 => 'qwe@gmail.com' ]; $res = $pdo->query("SELECT sku , product , qty , order_no FROM aveeva ORDER BY order_no, sku "); $orders = []; // // Split the items for each order // into groups depending the first // digit of their SKU // foreach ($res as $r) { $ono = array_pop($r); $sku1 = substr($r['sku'], 0, 1); if (!isset($addys[$sku1])) { $sku1 = 0; } $orders[$ono][$sku1][] = $r; } // // Build the email bodies from the array data // $emailsSent = ''; foreach ($orders as $ono => $odata) { foreach ($odata as $sku1 => $sdata) { $message = "<table border='1'> <caption>Order No: $ono</caption> <tr><th>SKU</th><th>Product</th><th>Quantity</th></tr>\n"; foreach ($sdata as $item) { $message .= "<tr><td>" . join("</td><td>", $item) . "</td></tr>\n"; } $message .= "</table>\n"; $emailsSent .= sendMailbasedOnSku($message, $addys, $sku1); } } function sendMailbasedOnSku($message, $addys, $sku1) { $emailTemplate = new Magee; $emailTemplate->setFromName('GIRI Test mail'); $emailTemplate->setBody($message); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); // GET THE APPROPRIATE EMAIL ADDRESS $sendTo = $addys[$sku1] ?? DEFAULT_ADDY; // USE IT $emailTemplate->setToEmail($sendTo); return $emailTemplate->send(); } ?> <html> <head> <title>Example</title> <style type='text/css'> body { font-family: clibri, sans-serif; font-size: 11pt;} fieldset { width: 70%; margin: 16px auto; padding: 16px;} legend { background-color: black; color: white; padding: 4px;} label { display: inline-block; width: 120px; font-weight: 600;} table { width: 50%; margin: 16px auto; border-collapse: collapse;} th { background-color: black; color: white; padding: 8px;} td { padding: 4px 8px;} </style> </head> <body> <?=$emailsSent?> </body> </html>
  35. 1 point
    Your problems are mainly because you are trying to write code before you have learnt to read. In my first post I said you needed 2 things. The first you have totally disregarded despite my spoonfeeding you the required code. The second addresses the problem you are now having and has also been ignored. Good luck and goodbye.
  36. 1 point
    Don't think about it in terms of references. Those are really just about &s. What PHP does with everything, not just arrays, is called copy-on-write. Meaning PHP will reuse a value up until you try to change it. That is when it starts making a copy. That's why they say never to use references to save memory: PHP is already saving memory for you.
  37. 1 point
    Get a copy of MySQL Workbench. There's a right-click menu option to go straight to it.
  38. 1 point
    First please use the code icon (<>) and choose PHP. It makes your code much easier to read. Which is line 118? Did you echo all your variables to make sure they contain what you expect?
  39. 1 point
    @mac_gyver gave the correct way to do it - http_build_query() EG $url = 'http://localhost/board/italian.php'; $data = [ 'page' => 2, 'country' => 'italian', 'comment' => 'this is a (simple) comment' ]; $qstr = http_build_query($data); $url .= '?' . $qstr; echo $url; //--> http://localhost/board/italian.php?page=2&country=italian&comment=this+is+a+%28simple%29+comment Note the encoding of the query string
  40. 1 point
    When you install a fresh wordpress website, the CMS by default create TWO config-php files which are: wp-config-sample.php wp-config.php Once, installation is done, then it is always recommended to remove "wp-config-sample.php" from the server, so that hackers can't use it to hack your website. Now coming, to your question, where did you added the DB Name, ID and Password? But, if your website was already live and shifted your wordpress website from one server to another then you may notice an 404 error all across the pages. This may be because of SSL issue and .htaccess. You may have to install and activate ssl on your website using cpanel read this. My website issue fixed using ssl installation.
  41. 1 point
    Oh damn, I didn't even see this thread when it was first created. Yeah, I don't know what happened. Nobody changed anything. Couple days ago I applied the latest IPB patch and the problem went away. I suspect it was some sort of template caching problem.
  42. 1 point
    There's no context around the code you've posted, but there appear to be a couple issues. First and foremost, you're using get_currentuserinfo() , which is deprecated in favor of wp_get_current_user(). Even beyond that, you're requesting the data of the currently logged in user, which is you. So actually your code is doing exactly what you've asked it to do. Another issue is that you're calling get_currentuserinfo() multiple times - if all this code is in the same template you don't need to do that. Give some context to what you're trying to do with this code. If you're in the WordPress loop, use the information about the current post.
  43. 1 point
    Of course, you could store the city and the full school name, then using the technique we discussed in this forum a couple of weeks ago, remove the city from the school name when required. I.E. SELECT school , city , TRIM(REPLACE(school, COALESCE(city,''), '')) as short_school FROM school; +------------------------------+----------------+----------------------+ | school | city | short_school | +------------------------------+----------------+----------------------+ | Bloomington North | Bloomington | North | | Columbus East | Columbus | East | | Fort Wayne Bishop Dwenger | Fort Wayne | Bishop Dwenger | | Neil Armstrong High | NULL | Neil Armstrong High | | Davy Crockett School | San Antonio | Davy Crockett School | | Kokomo | NULL | Kokomo | | Logansport | NULL | Logansport | | Marion | NULL | Marion | | Jefferson | Lafayette | Jefferson | | McCutcheon | Lafayette | McCutcheon | | Harrison | West Lafayette | Harrison | | Carmel Greyhounds | NULL | Carmel Greyhounds | | Zionsville Eagles | NULL | Zionsville Eagles | | Fishers Tigers | NULL | Fishers Tigers | | Noblesville Millers | NULL | Noblesville Millers | | Westfield Shamrocks | NULL | Westfield Shamrocks | | Hamilton Southeastern Royals | Hamilton | Southeastern Royals | +------------------------------+----------------+----------------------+
  44. 1 point
    IMO, you are just creating a problem mixing data. It doesn't matter if the school name is the same as the city. A city is a city, a school is a school.
  45. 1 point
    They are part of the language. Whenever possible you should always use the built in types and functions unless you have a very good reason not to.
  46. 1 point
  47. 1 point
  48. 1 point
    You simply rename wp-config-sample.php to wp-config.php or check this guide to fix database connection error. https://www.webminto.com/how-to-fix-error-establishing-a-database-connection-in-wordpress/
  49. 0 points
    The error is complaining about a comma in the code. There is no comma in that code.
  50. 0 points
    Have you tried adding some tracing to that code to see what it is doing, shows you values of things, etc? And who uses js script tags in the middle of their php logic?
This leaderboard is set to New York/GMT-05:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
×
×
  • 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.