Jump to content

kicken

Gurus
  • Posts

    4,694
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by kicken

  1. shell_exec is an example of where such functionality is used. The function is used to run a shell command, which is done by executing the shell program with -c. So in your code something like this: shell_exec('someCmd && someOtherCmd >/dev/null'); Is translated into /bin/sh -c 'someCmd && someOtherCmd >/dev/null' and executed by the OS. Essentially, the use case is for whenever you have a command stored in a string that you want to run. It's not something you'd typically use directly in a terminal, but rather in a script or program.
  2. You wouldn't do the comparisons in JavaScript, you'd do it in PHP when building your UPDATE query. Select the current data from the DB, compare it with what you received, then UPDATE whatever has changed. I wondered the same thing a while back, as this is something that Doctrine ORM does. I use MS SQL Server and from what brief searching I found, it does make a difference there. If I understand correctly, SQL Server like MySQL won't re-write the same data to disk, but it does record an entry in the transaction log. As such, unnecessary writes can cause increased overhead when it comes to transaction log management / replication. That said, I've never bothered doing this and instead just updating all the fields. I believe this level of optimization isn't really necessary until you get to pretty large applications. Adding the change detection complicates your PHP code and requires more processing overhead there so it's kind of a trade-off. Adding overhead to your PHP code and lowering the load on the DB is preferred though, as it's easier to scale your application code processing than it is to scale your database server.
  3. I would probably look into using WebSockets for this if possible. Have the clients connect to a WebSocket server and obtain the initial time to display. Each client handle updating the display itself using some local timing, potentially with a periodic sync. Whenever the admin pauses/starts the timer, broadcast that event + the current time to each client so they can pause/start their display and sync it.
  4. Yes, for example, in Thunderbird which is what I use, there is this setting: Unless that is checked, anything that requires accessing a remote server to display will not be loaded. The learn more link goes here if you're interested. Since I leave that setting off, most of the marketing emails I get end up like this: A little bit of text, lots of image placeholders / alt text. Some companies manage this better than others. Attaching images or using data: url's will allow them to show, but of course that doesn't help you with your desire to track things.
  5. Did you enable remote content in your email client? Most block it by default as far as I know.
  6. The extent of my searching experience is pretty much just WHERE clauses targeting specific columns, sometimes using LIKE for substring matches. Haven't really had a need for anything more complex than that yet. I was mostly just pointing out that there are dedicated search servers around and might be worth checking. Maybe they would be useful, maybe they won't, but worth checking out. As far as I understand, you would have to setup some kind of sync so if your metadata changes in your DB you update the the search index as well, so in a way you do have the data duplicated. There's a cost-benefit analysis to be made there for your needs.
  7. Are you trying to search the contents of the documents, or just the metadata (name, category, etc)? I've never looked into them much, but there are dedicated search servers you could look at as yet another alternative (Apache Solr being one example I've heard of).
  8. Does your new sub query return results for the range? If not, you'll need to left join it for you to still get a result set. Your column names also need to match. You're selecting larimarSales.totallarimar, but the sub-query defines the column as total.
  9. This bit of code is very antiquated. For new development, unless you have some need to support ancient IE systems, you should either just use new XMLHttpRequest unconditionally, or preferably, use fetch(). Part of your issue is also not understanding what this means in the code I think. this refers to whatever object a function is attached to. In your onload function, this will refer to your xmlhttp object. Outside of that function, this would refer to something else, so this.responseText outside the function is not the same as this.responseText inside the function. Outside the function, you'd use xmlhttp.responseText. My suggestion is you get rid of this code, and write your code using the modern fetch() api. That would look something like this: fetch('save_pool_history.php?action=select_past').then((response)=>{ if (!response.ok){ throw new Error('Invalid Response'); } return response.text(); }).then((text)=>{ alert(text); }).catch((error)=>{ alert('Error fetching response.'); });
  10. You put your join in the wrong place. You put your new join in between the an existing join's table name and it's join condition, which is not valid. You need to add your join either to the end of your query or between the existing joins (after one join's conditions, before the next join).
  11. Use LEFT JOIN instead of inner join for the joints to the sub-queries. You'll get NULL for reps with no sales. You can convert that null to a 0 in the select clause if you want by using COALESCE.
  12. select reps.rep_name, p41Sales.totalrum, allSales.total from reps inner join ( SELECT reps.rep_id, sum(sales.sales_totaldollars) as total FROM `sales` JOIN reps on reps.rep_id = sales.sales_repid AND reps.rep_touroperator_id = '5' AND reps.rep_active = 1 WHERE (sales.sales_date BETWEEN '2023-05-01' AND '2023-05-15') GROUP BY reps.rep_id ) allSales on allSales.rep_id=reps.rep_id inner join ( SELECT reps.rep_id, sum(salesdetails.salesdetails_pricedollars) as totalrum FROM `sales` JOIN salesdetails on salesdetails.salesdetails_salesticketnr = sales.sales_ticketnr JOIN reps on reps.rep_id = sales.sales_repid AND reps.rep_touroperator_id = '5' AND reps.rep_active = 1 WHERE (sales.sales_date BETWEEN '2023-05-01' AND '2023-05-15') AND salesdetails.salesdetails_productid = '41' GROUP BY reps.rep_name ) p41Sales on p41Sales.rep_id=reps.rep_id Your two independent queries become sub-queries that select the totals you want, grouped by rep ID. You join the results of those queries then to your reps table by the ID and output the rep details and the totals.
  13. Sounds like you want to separate totals. The total sales for Product 41 The overall total sales (for all products) Is that right? If so, you'd want to make two queries that will get you each of those totals, then use them as sub-queries in a third query that lists the reps.
  14. There is no sure-fire way to accomplish what you want to do. Whatever methods that do exist to try and automatically determine this are typically blocked or otherwise made useless for user privacy reasons. Many email clients for example will not load remote images by default, so your tracking pixel would not work. I think gmail takes the opposite approach and always loads the images, whether the email is read or not so it similarly provides no insight as to whether the user opened the email. You can add a tracking pixel to try and catch the few people using a client that will still load it. Otherwise the next best option is to add tracking data to all the links inside the email so if they click any of the links you will know about it. Even that type of tracking can sometimes be bypassed by clients.
  15. Not me, if I try and fill in the missing tables. Since I'm not all that well versed in this area, I don't really have much insight to provide without trying to setup some more complete test db. My general advice would be to not use the views for your updates. At least, not directly. You could probably still use the view to filter, but update the target table directly. For example, this fails with the error above: update _offers o set grade=5 where level=? But this works: update a_players p join _offers o on o.pid=p.id set p.grade=5 where o.level=? Otherwise maybe someone else with more mysql & view experience will chime in.
  16. I believe it's just the order by being there at all. With join's in the view, your update is a multi-table update, which the documentation for update says: If your view had no joins before then it would have probably worked but now with joins it will not. I'm in the habit of not including an ORDER BY clause in my views at all. I mostly use SQL Server which doesn't allow you to do so unless you apply a limit to the result set as well. The ORDER BY clause is generally intended to only exist in whatever the final query is, so you'd do: select whatever from yourView order by whatever rather than have the order by as part of the view.
  17. The ORDER By clause in your view was preventing my update attempt from working. Removing it allowed the update query to function. Did your queries have the order by clause before? Have you tried running an update query, or just going by the error your GUI tool is showing? Likely not related to the immediate problem, but you have a type mismatch in your DB. a_aau.aau_team_id is a VARCHAR being joined tot a_aau_teams.id which is an INT. The types should be matching, so you likely want to update your VARCHAR to be an INT as well.
  18. Screen shots are not useful. I can't import a screenshot into Mysql to work on it. Post the CREATE TABLE statements in a code block so they can be copy/pasted into mysql.
  19. If you post the structures of your tables, I can look into it more.
  20. I don't typically use updatable views, so I'm not sure. I don't see anything off hand. Is the query referencing other views, or only real tables? Does the query return multiple rows for the same p.id value?
  21. You can try reviewing the documentation on updatable views and see if you can spot a reason.
  22. Your fiddle doesn't really make sense. You keep referencing an element with id="demo" but no such element exists. In mouseOver you set the content, while in mouseOut you just change the color to black. Strange combination. Your mouseOver function is using your element variable, which is your id="butts" div. That div does not have a com attribute. It seems like you're just trying to add tool tips to your buttons. If you only want simple text-only tool tips, then you can just use the title attribute and not use JS at all. A JS solution is only needed if you want stylized tool tips, or for them to display in a specific place on the page. If you do need the JS, then what you want to do is add both your mouseover and mouseout event handlers to your butts element. On mouse over, check if the target element has a com attribute and if so display it. On mouse out, clear whatever has been set. Modified fiddle const element = document.getElementById("butts"); element.addEventListener("mouseover", mouseOver); element.addEventListener("mouseout", mouseOut); function mouseOver(e) { if (e.target.hasAttribute('com')){ let text = e.target.getAttribute("com"); document.getElementById("demo").textContent = text; } } function mouseOut(e) { document.getElementById("demo").textContent = ""; }
  23. The session ID is stored in a regular cookie, just like any other cookie data you would want to set. It has all the same cookie parameters, which can be configured with session_set_cookie_params. @jasonc310771 So long as the session cookie is setup with a domain parameter that allows it to be used on sub-domains, there should not be any issues with your session id carrying between domains. If the server-side code for both domains has access to the same session storage back end then sharing the data should work as well. If the two domains are hosted on different servers and you're using regular file based session handling, then the data won't carry over since the second server would not have access to the first server's session files. Have you checked if the session ID is being carried between domains by inspecting the requests your browser makes using it's dev tools? If it's not, try using the session_set_cookie_params function to setup your domain parameter prior to calling session_start().
  24. The .style.* properties only provide values directly assigned to an element, either via JS or via a style="" attribute, they do not reflect CSS applied via selectors. For that, you need to use getComputedStyle. I do not see anything in your current code that is changing the left attribute of your elements, so it'd never change to be zero. Scrolling does not affect the left attribute of an element if that was your intent. If you want to check if something has been scrolled out of view, you need to find the scroll position and compare it to the position of the element.
  25. You are setting the values by ID, but IDs must be unique within a document, referring to only a single element. You need to find the row that the data needs to be associated with, then set the values to the inputs in that row using something like querySelector and a class name. I think the first question to ask is how do you determine which row to associate the data with?
×
×
  • 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.