Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Can you tell us what you are trying to achieve? It's impossible to tell from that hotchpotch of code.
  2. What does your function arary_multisort() do? Are you wanting something like this (sorting them in the query) ... $res = $conn->query("SELECT option_id , id FROM bets WHERE win_status = '1' AND updated_at BETWEEN '2021-05-01 13:00:00.000000' AND '2021-05-02 08:00:00.000000' ORDER BY option_id, id "); $info = []; foreach ($res as $row) { $info[$row['option_id']][] = $row['id']; } echo '<pre>', print_r($info, 1), '</pre>'; giving Array ( [game1a] => Array ( [0] => 255670450 [1] => 255670900 [2] => 455670450 ) [game2h] => Array ( [0] => 126887550 [1] => 386887537 [2] => 486887537 ) )
  3. Depends on the column definition for your date/time column (DATETIME or TIMESTAMP) From the manual ... The limit of a timestamp is the maximum value of a signed integer, mysql> SELECT from_unixtime(2147483647); +---------------------------+ | from_unixtime(2147483647) | +---------------------------+ | 2038-01-19 03:14:07 | +---------------------------+ When storing dates and times in a database, use DATETIME, TIMESTAMP, DATE or TIME types. As well as DATE AND DATETIME having a greater date range, they are infinitely more readable for mere humans.
  4. I ran your code and it functions OK. The only way I can see that $result is not defined is if $_GET['id'] is empty or not an integer. But you say that you are inputting a valid id value so I'm out of guesses. Good luck.
  5. Have you got PDO and PHP error reporting options set?
  6. Do you still get that notice if you enter a valid id?
  7. Instead of using hyphens, use array indices in your form input field names <input type="text" name="guestname[0]" > <input type="text" name="guestname[1]" >
  8. If you use an aggregation function (SUM, COUNT, AVG etc) without a GROUP BY clause you get a single aggregation (row) for the whole table. Don't use "SELECT * ", especially with aggregations. Don't run queries inside loops. Get the data you need with a single query Don't litter the forum with multiple threads on the same topic. From your earlier post it looked like you want the average daily total for each month SELECT YEAR(day) as yr , MONTH(day) as mth , AVG(price) as avprice FROM ( SELECT DATE(order_datetime) as day , SUM(purchase_price) as price FROM ordered_items WHERE YEAR(order_datetime) = YEAR(CURDATE()) AND order_status = 5 GROUP BY day ) daily GROUP BY yr, mth;
  9. See https://www.php.net/manual/en/language.variables.external.php
  10. DOH! 🙄 Forgot to include the flat charge in the spreadsheet total formula (copied the "Units" total formula) and also completely missed the VAT element. Thus demonstrating the perils of copy/paste - a warning to all.
  11. Sorry, don't know a solution that will give you 914.01.
  12. You don't say what the problem is, but WHERE username = !null - WRONG WHERE username IS NOT NULL - CORRECT;
  13. Aside from that, mysql will only report that the combination of username, password and domain was invalid, not which portions.
  14. How to help your local neighbourhood hacker - let them know whether it was the username or the password that they got wrong. At least then they know they are half-way there.
  15. Remind me - what's that saying about a workman and his tools?
  16. That line is a waste of time. If you have startup errors the code isn't going to run to execute it. Error handling should be set in the php.ini file, not in every script.
  17. The key names there - you just have to use it. $myArray = array(); $myArray[0]['Name'] = 'fred'; $myArray[0]['Age'] = 55; $myArray[1]['Name'] = 'Joe'; $myArray[1]['Age']= 765; echo '<pre>', print_r($myArray, 1), '</pre>'; foreach ($myArray as $key => $value): echo "<br><b>Person $key:</b><br>"; foreach ($value as $k => $v) { echo " &bull; $k : $v<br>"; } endforeach; Outputs Array ( [0] => Array ( [Name] => fred [Age] => 55 ) [1] => Array ( [Name] => Joe [Age] => 765 ) ) Person 0: • Name : fred • Age : 55 Person 1: • Name : Joe • Age : 765
  18. The usual method for processing an array is with "foreach" which gets you the key and value on each iteration foreach ($myArray[$i] as $key => $value) { if isInvalid($key, $value) { report($key); } }
  19. You need to provide context details and a better explanation than that if you want any meaningful replies.
  20. F***ed Up Beyond All Recognition. I think it's an army acronym, like SNAFU(Situation Normal, All F***ed Up)
  21. I still don't understand the process going on here but the feel of that table is wrong - it has a distinct unnormalized aroma about it, as though it should be 2 tables without triple keys..
  22. What are these fields? `original_request_id` int(11) NOT NULL, `ref_request_id` int(11) DEFAULT NULL,
  23. All that line does in your ajax script is send the name of the file. It is NOT uploading the file. https://www.php.net/manual/en/features.file-upload.php
×
×
  • 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.