-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
WHERE id = ? AND FirstImage IN (0,1)
-
Can you tell us what you are trying to achieve? It's impossible to tell from that hotchpotch of code.
-
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 ) )
-
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.
-
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.
-
Have you got PDO and PHP error reporting options set?
-
Do you still get that notice if you enter a valid id?
-
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]" >
-
how to use the values get in AJAX method in sql query?
Barand replied to sashavalentina's topic in PHP Coding Help
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; -
See https://www.php.net/manual/en/language.variables.external.php
-
You don't say what the problem is, but WHERE username = !null - WRONG WHERE username IS NOT NULL - CORRECT;
-
Different error messages in connection mysqli script.
Barand replied to LeonLatex's topic in PHP Coding Help
Aside from that, mysql will only report that the combination of username, password and domain was invalid, not which portions. -
Different error messages in connection mysqli script.
Barand replied to LeonLatex's topic in PHP Coding Help
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. -
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 " • $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
-
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); } }
-
You need to provide context details and a better explanation than that if you want any meaningful replies.
-
F***ed Up Beyond All Recognition. I think it's an army acronym, like SNAFU(Situation Normal, All F***ed Up)
-
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..
-
What are these fields? `original_request_id` int(11) NOT NULL, `ref_request_id` int(11) DEFAULT NULL,