-
Posts
24,604 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
Neither of those conditions I mentioned are "errors" that would generate an error message. However, how you deal with them could be different.
-
If you get back an empty value for the price, how will you know whether it's because the record didn't exist or because there was no price in the record? Most times, when you need a query like that, the value ('small' in this case) will be from the user via GET or POST. Then you need a prepared query, which is going to upset your applecart.
-
Try $start_from = ($page - 1) * $num_per_page;
-
sql| 2005 MSSQL connection error with xampp 1.7.3
Barand replied to DarkVision's topic in Microsoft SQL - MSSQL
Have you tried using Microsoft's sqlsrv library? (i have feeling that replaced the mssql library) Or PDO with SQLserver driver? -
No, it isn't. You'll find that the final " is missing after the "sales-channel" $result .= '"'.$order->sales_channel. "\n"; should be $result .= '"'.$order->sales_channel. "\"\n"; That aside, I can't see multiple writes in the function. My guesses at the moment It is being called multiple times, each call writing a single record. It is being call recursively (What does wp_remote_post( admin_url('admin-ajax.php?action=get_batch_orders_from_api') do inside the function?
-
Your $result string contains only one comma (after the SKU). Where do the others come from in your listed output? Are you sure that's the code causing the problem?
-
Having an unexpected issue with CASE in my query...
Barand replied to Jim R's topic in PHP Coding Help
Your three player_offers results effectively contain +----------------+-------------------+----------------+----------------+--------------+ | player_id | offers | time | commit | decommit | +----------------+-------------------+----------------+----------------+--------------+ | 808 | | | | College B | | 808 | | | College B | | | 808 | College A | 2021-04-15 | | | +----------------+-------------------+----------------+----------------+--------------+ Because the grouping only gives you one row per player, only results from one of them will be chosen by the query to appear. You see the offer data because that is aggregated (GROUP_CONCAT) to one value for the player, but you will process either the commit or decommit (if they are not aggregated.). All you are doing by removing the commit CASE is choosing not to show the data from the row it's chosen to use. -
Having an unexpected issue with CASE in my query...
Barand replied to Jim R's topic in PHP Coding Help
Removing the commit column doesn't change the fact that you have three records for the one player in players_offers. As I said, you'll only get values from one of them as other columns are aggregated. ... exactly. Try making them GROUP_CONCAT (or some other aggregation,eg MAX) like the others -
Can't figure out why HTML blocks won't change
Barand replied to TechnoDiver's topic in PHP Coding Help
I told you that same thing about nl2br() in a previous post of yours. I guess some seeds fall on stony ground. -
Having an unexpected issue with CASE in my query...
Barand replied to Jim R's topic in PHP Coding Help
That is either by good luck or poor checking. If a player has only a single "commit/decommit" record in players_offers, it will work fine. Once you get multiple records you will only see the results from one of them because of the grouping. If you get a result for "commit" you won't see the one for "decommit", and vice versa. -
Having an unexpected issue with CASE in my query...
Barand replied to Jim R's topic in PHP Coding Help
You are using an aggregation function (GRUP_CONCAT) in a query without a GROUP BY clause. The query, therefore, will only return a single row. The values in that row that are not aggregated will be arbitrary. -
PHP: GET JSON from URL and structure it in HTML
Barand replied to Zorglub's topic in PHP Coding Help
All you told us is that the cUrl returns $response. The answer is proportional to the detail in the question. Your "example without authentication" seems to provide your own answer. -
PHP: GET JSON from URL and structure it in HTML
Barand replied to Zorglub's topic in PHP Coding Help
Example... <?php //The URL of the resource that is protected by Basic HTTP Authentication. $url = 'https://gw.bilinfo.net/listingapi/api/export'; //Your username. $username = 'demo'; //Your password. $password = 'ocfB6XzF73'; //Initiate cURL. $ch = curl_init($url); //Specify the username and password using the CURLOPT_USERPWD option. curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); //Tell cURL to return the output as a string instead //of dumping it to the browser. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Execute the cURL request. $response = curl_exec($ch); //Check for errors. if(curl_errno($ch)){ //If an error occured, throw an Exception. throw new Exception(curl_error($ch)); } ?> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Sample</title> </head> <body> <?= $response; ?> </body> </html> -
I'd just use a loop foreach ($arr['data'] as &$a) { $a['location'] = ucwords(strtolower($a['location'])); } array_map ain't going to play nice with nested arrays.
-
Assign values from the range [.....N] to the vertices of the graph
Barand replied to RohanH's topic in PHP Coding Help
-
Assign values from the range [.....N] to the vertices of the graph
Barand replied to RohanH's topic in PHP Coding Help
vertices values are 3,5,2,4,1 Is there rule for what values are applied to the vertices? I haven't spotted the pattern yet. -
Assign values from the range [.....N] to the vertices of the graph
Barand replied to RohanH's topic in PHP Coding Help
OK, that answers that question. Next, you say you want a function that ... The example you gave has only one sum (31). To find a maximum you need more than one. To get more than one value, something is going to have to vary in value (presumably between fixed limits). So is there something else that you aren't telling us? PS Just seen your latest post. Is that 0.5pt text in your image supposed to be legible? -
Assign values from the range [.....N] to the vertices of the graph
Barand replied to RohanH's topic in PHP Coding Help
-
Assign values from the range [.....N] to the vertices of the graph
Barand replied to RohanH's topic in PHP Coding Help
Your example: A=[2, 2, 1, 3] : : : : B=[1 ,3 ,4, 4] the graph has 4 edges: (2,1),(2,3),(1,4),(2,4) Why is the fourth edge (2,4) and not (3,4) ? -
input +----+---------------+----------+-------+---------------------+ | id | license_plate | car_bike | price | create_date | +----+---------------+----------+-------+---------------------+ | 1 | BA12ECD | 1 | 5.50 | 2021-08-21 08:09:51 | | 3 | DA12ECD | 1 | 8.50 | 2021-08-21 08:09:51 | | 6 | GA12ECD | 1 | 5.50 | 2021-08-21 08:09:51 | | 7 | HA12ECD | 1 | 8.50 | 2021-08-21 08:09:51 | | 2 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 4 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 5 | | 2 | 1.50 | 2021-08-21 08:09:51 | | 8 | BB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 10 | DB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 13 | GB12ECD | 1 | 9.50 | 2021-08-22 08:09:51 | | 14 | HB12ECD | 1 | 5.50 | 2021-08-22 08:09:51 | | 9 | | 2 | 1.50 | 2021-08-22 08:09:51 | +----+---------------+----------+-------+---------------------+ query SELECT date(create_date) as parking_date , car_bike , count(*) as num , sum(price) as tot FROM tb_parking_group GROUP BY parking_date, car_bike WITH ROLLUP; output +--------------+----------+-----+-------+ | parking_date | car_bike | num | tot | +--------------+----------+-----+-------+ | 2021-08-21 | 1 | 4 | 28.00 | | 2021-08-21 | 2 | 3 | 4.50 | | 2021-08-21 | NULL | 7 | 32.50 | <-- day subtotal | 2021-08-22 | 1 | 4 | 26.00 | | 2021-08-22 | 2 | 1 | 1.50 | | 2021-08-22 | NULL | 5 | 27.50 | <-- day subtotal | NULL | NULL | 12 | 60.00 | <-- total +--------------+----------+-----+-------+
- 1 reply
-
- 1
-
-
fill array with " " to avoid "undefined index" errors?
Barand replied to ChenXiu's topic in PHP Coding Help
If you do want to replace null values with, say, '' (an empty string), then you could do this (usng my above array)... $myarr = array_map('denullify', $myarr); function denullify($v) { return $v ?? ''; }