-
Who's Online 1 Member, 0 Anonymous, 78 Guests (See full list)
All Activity
- Past hour
-
sdagasdgsdagasgsd joined the community
- Today
-
In the end I just went with tcpdf was quite simple and very fast to generate. PDF generation is much faster then my current PSA tool. Filesize is also small on the pdfs generated.
-
I'd take the easy way out and use the database with a single query DATA TABLE : season; TABLE : price +-----------+----------------+------------+------------+--------+ +----+--------+------+-------+ | season_id | name | start_date | end_date | tariff | | id | tariff | day | price | +-----------+----------------+------------+------------+--------+ +----+--------+------+-------+ | 1 | Winter 2024 | 2024-11-01 | 2024-12-23 | LO | | 1 | ST | 0 | 70 | day 0 = Monday | 2 | Christmas 2024 | 2024-12-24 | 2025-01-02 | PK | | 2 | ST | 1 | 70 | | 3 | Easter 2025 | 2025-04-11 | 2025-04-27 | PK | | 3 | ST | 2 | 70 | | 4 | Summer 2025 | 2025-06-15 | 2025-08-31 | HI | | 4 | ST | 3 | 70 | +-----------+----------------+------------+------------+--------+ | 5 | ST | 4 | 90 | | 6 | ST | 5 | 90 | | 7 | ST | 6 | 70 | day 6 = Sunday TABLE : tariff | 8 | LO | 0 | 55 | +--------+-------------+ | 9 | LO | 1 | 55 | | tariff | description | | 10 | LO | 2 | 55 | +--------+-------------+ | 11 | LO | 3 | 55 | | HI | High season | | 12 | LO | 4 | 75 | | LO | Low season | | 13 | LO | 5 | 75 | | PK | Peak season | | 14 | LO | 6 | 55 | | ST | Standard | | 15 | HI | 0 | 90 | +--------+-------------+ | 16 | HI | 1 | 90 | | 17 | HI | 2 | 90 | TABLE : booking | 18 | HI | 3 | 90 | +----+------------+---------+------------+ | 19 | HI | 4 | 110 | | id | booking_no | room_no | book_date | | 20 | HI | 5 | 110 | +----+------------+---------+------------+ | 21 | HI | 6 | 90 | | 1 | 1 | 1 | 2025-05-07 | | 22 | PK | 0 | 110 | | 2 | 1 | 1 | 2025-05-08 | | 23 | PK | 1 | 110 | | 3 | 1 | 1 | 2025-05-09 | | 24 | PK | 2 | 110 | | 4 | 2 | 5 | 2025-04-25 | | 25 | PK | 3 | 110 | | 5 | 2 | 5 | 2025-04-26 | | 26 | PK | 4 | 125 | | 6 | 2 | 5 | 2025-04-27 | | 27 | PK | 5 | 125 | | 7 | 2 | 5 | 2025-04-28 | | 28 | PK | 6 | 110 | | 8 | 2 | 5 | 2025-04-29 | +----+--------+------+-------+ | 9 | 2 | 5 | 2025-04-30 | +----+------------+---------+------------+ QUERY SELECT b.booking_no , MIN(b.book_date) as `from` , MAX(b.book_date) as until , SUM(p.price) as total FROM booking b LEFT JOIN season s ON b.book_date between s.start_date AND s.end_date LEFT JOIN price p ON coalesce(s.tariff, 'ST') = p.tariff -- tariff defaults to "ST" if no seasons match date AND p.day = weekday(b.book_date) GROUP BY b.booking_no; +------------+------------+------------+-------+ | booking_no | from | until | total | +------------+------------+------------+-------+ | 1 | 2025-05-07 | 2025-05-09 | 230 | | 2 | 2025-04-25 | 2025-04-30 | 570 | +------------+------------+------------+-------+
-
mchojrin joined the community
-
It doesn't change the fact that the code in vsp.php at line 2392 is trying to get the value of the constant LOG_READ_SIZE and LOG_READ_SIZE is undefined. As far as I can see there is no way to look at the source code. I did see that someone dockerized the app and put the source code in github, but the actual vsp code is in some zip file that the package downloads.
-
I've managed to sort it and it works perfectly. I've also put it into a class, here is code if anyone wants to use it. Thank you for all your help! class Calendar { public static function bookedArray($strDateFrom,$strDateTo) { $aryRange = []; $iDateFrom = strtotime($strDateFrom); $iDateTo = strtotime($strDateTo); if ($iDateTo >= $iDateFrom) { array_push($aryRange, date('Y-m-d', $iDateFrom)); // first entry while ($iDateFrom<$iDateTo) { $iDateFrom += 86400; // add 24 hours array_push($aryRange, date('Y-m-d', $iDateFrom)); } } return $aryRange; } public static function flattenCalendar($array) { $flatArray = []; array_walk_recursive($array, function($value) use (&$flatArray) { $flatArray[] = $value; }); return $flatArray; } public static function estimatePrice($checkin, $checkout, $stdArray, $specArray) { $requestDates = self::bookedArray($checkin, $checkout); $specialRate = array(); $standardRate = array(); $cost = array(); //return var_dump($requestDates); if(!empty($stdArray)) { foreach($stdArray as $row) { if($row->SeasonName == 'Standard Weekday') { $standardRate['Weekday'] = $row->SeasonPrice; } if($row->SeasonName == 'Standard Weekend') { $standardRate['Weekend'] = $row->SeasonPrice; } } } if(!empty($specArray)) { $i = 0; foreach($specArray as $row) { $specialRate[$i]['start'] = $row->SeasonStart; $specialRate[$i]['end'] = $row->SeasonEnd; $specialRate[$i]['price'] = $row->SeasonPrice; $i++; } } $specialCount = count($specialRate); $standardCount = count($stdArray); $flatRequest = self::flattenCalendar($requestDates); // Reqested Dated into One Array $cost = array(); $specialCost = array(); $days = count($flatRequest); foreach($flatRequest as $key => $val) { $specialDays = 0; for($i=0; $i<count($specialRate); $i++) { $range = self::bookedArray($specialRate[$i]['start'], $specialRate[$i]['end']); array_pop($range); if(in_array($val, $range)) { array_push($specialCost, $specialRate[$i]['price']); $specialDays++; unset($flatRequest[$key]); } } } array_pop($flatRequest); foreach($flatRequest as $key => $val) { if( date('l', strtotime($val)) == 'Saturday' || date('l', strtotime($val)) == 'Sunday' ) { array_push($cost, $standardRate['Weekend']); } else { array_push($cost, $standardRate['Weekday']); } } if(!empty($cost) && !empty($specialCost)) { return array_sum(array_merge($cost, $specialCost)); } elseif(!empty($specialCost) && empty($cost)) { array_pop($specialCost); return array_sum($specialCost); } else { return array_sum($cost); } } }
- Yesterday
-
here's a tested example showing the suggested method - <?php // fake a request start and end date - 1st May 2025 to 8th May 2025 $start_date = "2025-05-01"; $end_date = "2025-05-08"; // exclude check-out date from length of stay/pricing $end = new DateTime($end_date); $end = $end->modify( '-1 day' ); $end_date = $end->format("Y-m-d"); // define default weekday and weekend prices $default_price = []; $default_price['wd'] = (object)['name'=>'Standard Weekday','price'=>'60']; $default_price['we'] = (object)['name'=>'Standard Weekend','price'=>'80']; // define seasonal prices $seasonPrices = []; $seasonPrices[] = (object)["SeasonName"=>"Spring half-term", "SeasonStart"=>'2025-02-21', "SeasonEnd"=>'2025-03-03', "SeasonPrice"=>'100']; $seasonPrices[] = (object)["SeasonName"=>"Easter", "SeasonStart"=>'2025-04-11', "SeasonEnd"=>'2025-04-27', "SeasonPrice"=>'100']; $seasonPrices[] = (object)["SeasonName"=>"May Day", "SeasonStart"=>'2025-05-02', "SeasonEnd"=>'2025-05-05', "SeasonPrice"=>'110']; $seasonPrices[] = (object)["SeasonName"=>"Summer half-term", "SeasonStart"=>'2025-05-23', "SeasonEnd"=>'2025-06-01', "SeasonPrice"=>'110']; $seasonPrices[] = (object)["SeasonName"=>"Summer", "SeasonStart"=>'2025-07-18', "SeasonEnd"=>'2025-09-01', "SeasonPrice"=>'120']; $seasonPrices[] = (object)["SeasonName"=>"Autumn half-term", "SeasonStart"=>'2025-10-24', "SeasonEnd"=>'2025-11-02', "SeasonPrice"=>'110']; $seasonPrices[] = (object)["SeasonName"=>"Christmas", "SeasonStart"=>'2025-12-19', "SeasonEnd"=>'2026-01-04', "SeasonPrice"=>'120']; // start by creating an array of request dates filled with the default weekday price $request = array_fill_keys(Cal::bookedArray($start_date, $end_date), $default_price['wd']->price); // get the weekend prices between the request start and end dates $weekend_prices = get_we_prices($start_date,$end_date,$default_price); // put the weekend prices into the array $request = array_replace($request,$weekend_prices); // get the seasonal prices between the request start and end dates $season_prices = get_prices($start_date,$end_date,$seasonPrices); // put the seasonal prices into the array $request = array_replace($request,$season_prices); // examine the result echo '<pre>'; print_r($request); echo '</pre>'; echo "Total: " . array_sum($request); // get the weekend prices between the request start and end dates function get_we_prices($start_date,$end_date,$default_price) { $dates = []; // find 1st Sat of the start date $date = date('Y-m-d',strtotime("first sat of $start_date")); // generate all the Saturdays between the start and end dates $start = new DateTime($date); $end = new DateTime($end_date); $end = $end->modify( '+1 day' ); // include the end point $interval = new DateInterval('P7D'); // 7 days $daterange = new DatePeriod($start, $interval ,$end); foreach($daterange as $date){ $dates[$date->format("Y-m-d")] = $default_price['we']->price; } // same as above but for Sundays // find 1st Sun of the start date $date = date('Y-m-d',strtotime("first sun of $start_date")); // generate all the Sundays between the start and end dates $start = new DateTime($date); $end = new DateTime($end_date); $end = $end->modify( '+1 day' ); // include the end point $interval = new DateInterval('P7D'); // 7 days $daterange = new DatePeriod($start, $interval ,$end); foreach($daterange as $date){ $dates[$date->format("Y-m-d")] = $default_price['we']->price; } return $dates; } // get the seasonal prices between the request start and end dates function get_prices($start,$end,$seasonPrices) { $result = []; foreach($seasonPrices as $row) { // keep entries that match the requested start/end // SeasonEnd >= start AND end >= SeasonStart if($row->SeasonEnd >= $start && $end >= $row->SeasonStart) { // expand this entry and only keep the values between the start and end (for the case of spanning the start or end date) $entry = Cal::bookedArray($row->SeasonStart, $row->SeasonEnd); foreach($entry as $date) { // if date between start and end, keep it if($start <= $date && $date <= $end) { $result[$date] = $row->SeasonPrice; } } } } return $result; } class cal { // produce a date range from start to end public static function bookedArray($start,$end) { $start = new DateTime($start); $end = new DateTime($end); $end = $end->modify( '+1 day' ); // include the end point $interval = new DateInterval('P1D'); // 1 day $daterange = new DatePeriod($start, $interval ,$end); $dates = array(); foreach($daterange as $date){ $dates[] = $date->format("Y-m-d"); } return $dates; } }
-
you are constantly changing data types, names, and adding features. this makes writing code extremely wasteful. you need to define everything possible, before you write any code. you also need to define what inputs you have for any operation, what processing you are going to do based on those inputs, and what result or output you are going to produce. as to a simple, straightforward solution, i recommend that you read the suggestions in the previous thread, about building an array with the dates as the array index and the values being whatever you are trying to produce. in that thread, the array was for the special events for the calendar being displayed. in this thread, the array is for the requested date range and the price for each day in that range. the inputs to this code are the start and end dates of the request, the standard week day and week end prices, and the seasonal pricing. you would start by creating an array using the request range of dates as the array index. you would fill in the array with the week day and week end prices. you would then replace any price that matches the seasonal pricing data. when you are done, you will have an array with all the days of the request as the index, and the price for each day. you can then just sum the prices to get the total. here's a procedural function that gets the seasonal prices, given the request start and end date - // get seasonal prices between start and end date function get_prices($start,$end,$seasonPrices) { $result = []; foreach($seasonPrices as $row) { // keep entries that match the requested start/end // SeasonEnd >= start AND end >= SeasonStart if($row->SeasonEnd >= $start && $end >= $row->SeasonStart) { // expand this entry and only keep the values between the start and end (for the case of spanning the start or end date) $entry = Cal::bookedArray($row->SeasonStart, $row->SeasonEnd); foreach($entry as $date) { // if date between start and end, keep it if($start <= $date && $date <= $end) { $result[$date] = $row->SeasonPrice; } } } } return $result; } you can use array_replace() with the array you are building and the array returned by the above function to replace the standard prices in that array with the seasonal prices.
-
So far this is what code I have if(!empty($standardRates)) { foreach($standardRates as $row) { if($row->SeasonName == 'Standard Weekday') { $standardRate['Weekday'] = $row->SeasonPrice; } if($row->SeasonName == 'Standard Weekend') { $standardRate['Weekend'] = $row->SeasonPrice; } } } if(!empty($setPrices)) { $i = 0; foreach($setPrices as $row) { $specialRate[$i]['start'] = $row->SeasonStart; $specialRate[$i]['end'] = $row->SeasonEnd; $specialRate[$i]['price'] = $row->SeasonPrice; $i++; } } $cost = array(); foreach($flatRequest as $key => $val) { for($i=0; $i<count($specialRate); $i++) { if(in_array($val, Cal::bookedArray($specialRate[$i]['start'], $specialRate[$i]['end']))) { array_push($cost, $specialRate[$i]['price']); } } if(empty($specialRate)) { if(date('l', strtotime($val)) == 'Saturday' || date('l', strtotime($val)) == 'Sunday') { array_push($cost, $standardRate['Weekend']); } else { array_push($cost, $standardRate['Weekday']); } } } This doesn't work though, $cost is empty
-
I'll just put what i am trying to achieve instead of the code i am using I have 2 arrays with stored days and prices # Standard Days Array ( [0] => stdClass Object ( [name] => Standard Weekday [price] => 60 ) [1] => stdClass Object ( [name] => Standard Weekend [price] => 80 ) ) # Special Days Array ( [0] => Array ( [start] => 2025-02-21 [end] => 2025-03-03 [price] => 100 ) [1] => Array ( [start] => 2025-04-11 [end] => 2025-04-27 [price] => 100 ) [2] => Array ( [start] => 2025-05-02 [end] => 2025-05-05 [price] => 110 ) [3] => Array ( [start] => 2025-05-23 [end] => 2025-06-01 [price] => 110 ) [4] => Array ( [start] => 2025-07-18 [end] => 2025-09-01 [price] => 120 ) [5] => Array ( [start] => 2025-10-24 [end] => 2025-11-02 [price] => 110 ) [6] => Array ( [start] => 2025-12-19 [end] => 2026-01-04 [price] => 120 ) ) I want to get the prices from those arrays for each day from the selected dates, so from 1st May 2025 to 8th May 2025 would look like this # Selected Days Array ( [0] => 2025-05-01 [1] => 2025-05-02 [2] => 2025-05-03 [3] => 2025-05-04 [4] => 2025-05-05 [5] => 2025-05-06 [6] => 2025-05-07 [7] => 2025-05-08 ) so for each of the Selected Days if the date is not in the Special Days array it will give me the price of the standard weekday or weekend, If it is in the special date it will give me that instead. Because there are no special dates in the selected days it would calculate (5x60)+(2x80) so give a total of 460. Its when there is special dates where i am having the issue, how can i check each selected day in the special days array and get the price for that array
-
Leloror joined the community
- Last week
-
Your wording and examples are a bit all over the place, I believe you're trying to filter an array, and then manipulate any specific ones that match particular date. Right? So, if 5/5/25 is a day with a special rate, and is within the date range provided by the user, use the "special" price? You can use array_map to manipulate the items that match a specific date. An example of it being used for only one "special" date - May 5 2025 $dates = [ '2025-05-01', '2025-05-02', '2025-05-03', '2025-05-04', '2025-05-05', ]; $specialDate = '2025-05-05'; $specialPrice = 8.00; // The special price to apply ONLY on $specialDate $priceUpdateCallback = function ($item) use ($specialDate, $specialPrice) { $element = ["date" => $item, "price" => 10]; if ($item == $specialDate) { $element['date'] = $specialDate; $element['price'] = $specialPrice } return $element; }; $result = array_map('priceUpdateCallback', $dates); echo "<pre>", print_r($result), "</pre>"; Should give you something like Array ( .............Array ( [date] => 2025-05-05 [price] => 8 ) )
-
for the posted information, the requested date range of 2025-05-06 to 2025-05-22 doesn't match any of the $seasonPrices data. It starts one day after the end of the May Day range and ends one day before the start of the Summer half-term range. it should use the base/default price for every day. since you are using a standard date format, you can directly perform date comparisons by order, as mentioned in the previous thread. you can directly compare a date to the $seasonPrices SeasonStart and SeasonEnd values to find if it is between a date range. i would write a function/class-method that accepts a date input, loops over the $seasonPrices data, returns the first price that is between the SeasonStart and SeasonEnd values, or returns zero (or some other easily detected value) if it reaches the end without finding a match. as a procedural function, something like - function get_price($date,$seasonPrices) { foreach($seasonPrices as $row) { // date between start and end if($row->SeasonStart <= $date && $date <= $row->SeasonEnd) { return $row->SeasonPrice; } } // no match return 0; }
-
I am trying to get values from an array with a date range This is the var_dump assuming from date is 06 May 2025 and to date is 22 May 2025 [0]=> string(10) "2025-05-06" [1]=> string(10) "2025-05-07" [2]=> string(10) "2025-05-08" [3]=> string(10) "2025-05-09" [4]=> string(10) "2025-05-10" [5]=> string(10) "2025-05-11" [6]=> string(10) "2025-05-12" [7]=> string(10) "2025-05-13" [8]=> string(10) "2025-05-14" [9]=> string(10) "2025-05-15" [10]=> string(10) "2025-05-16" [11]=> string(10) "2025-05-17" [12]=> string(10) "2025-05-18" [13]=> string(10) "2025-05-19" [14]=> string(10) "2025-05-20" [15]=> string(10) "2025-05-21" [16]=> string(10) "2025-05-22" It then searches the following array $count = 0; foreach($seasonPrices as $row) { $price[$count]['name'] = $row->SeasonName; $price[$count]['days'] = implode(',', Cal::bookedArray($row->SeasonStart, $row->SeasonEnd)); $price[$count]['price'] = $row->SeasonPrice; $count++; } unset($count); [2]=> array(3) { ["name"]=> string(16) "Spring half-term" ["days"]=> string(120) "2025-02-21,2025-02-22,2025-02-23,2025-02-24,2025-02-25,2025-02-26,2025-02-27,2025-02-28,2025-03-01,2025-03-02,2025-03-03" ["price"]=> string(3) "100" } [3]=> array(3) { ["name"]=> string(6) "Easter" ["days"]=> string(186) "2025-04-11,2025-04-12,2025-04-13,2025-04-14,2025-04-15,2025-04-16,2025-04-17,2025-04-18,2025-04-19,2025-04-20,2025-04-21,2025-04-22,2025-04-23,2025-04-24,2025-04-25,2025-04-26,2025-04-27" ["price"]=> string(3) "100" } [4]=> array(3) { ["name"]=> string(7) "May Day" ["days"]=> string(43) "2025-05-02,2025-05-03,2025-05-04,2025-05-05" ["price"]=> string(3) "110" } [5]=> array(3) { ["name"]=> string(16) "Summer half-term" ["days"]=> string(109) "2025-05-23,2025-05-24,2025-05-25,2025-05-26,2025-05-27,2025-05-28,2025-05-29,2025-05-30,2025-05-31,2025-06-01" ["price"]=> string(3) "110" } [6]=> array(3) { ["name"]=> string(6) "Summer" ["days"]=> string(505) "2025-07-18,2025-07-19,2025-07-20,2025-07-21,2025-07-22,2025-07-23,2025-07-24,2025-07-25,2025-07-26,2025-07-27,2025-07-28,2025-07-29,2025-07-30,2025-07-31,2025-08-01,2025-08-02,2025-08-03,2025-08-04,2025-08-05,2025-08-06,2025-08-07,2025-08-08,2025-08-09,2025-08-10,2025-08-11,2025-08-12,2025-08-13,2025-08-14,2025-08-15,2025-08-16,2025-08-17,2025-08-18,2025-08-19,2025-08-20,2025-08-21,2025-08-22,2025-08-23,2025-08-24,2025-08-25,2025-08-26,2025-08-27,2025-08-28,2025-08-29,2025-08-30,2025-08-31,2025-09-01" ["price"]=> string(3) "120" } [7]=> array(3) { ["name"]=> string(16) "Autumn half-term" ["days"]=> string(120) "2025-10-24,2025-10-25,2025-10-26,2025-10-26,2025-10-27,2025-10-28,2025-10-29,2025-10-30,2025-10-31,2025-11-01,2025-11-02" ["price"]=> string(3) "110" } [8]=> array(3) { ["name"]=> string(10) "Christmas " ["days"]=> string(186) "2025-12-19,2025-12-20,2025-12-21,2025-12-22,2025-12-23,2025-12-24,2025-12-25,2025-12-26,2025-12-27,2025-12-28,2025-12-29,2025-12-30,2025-12-31,2026-01-01,2026-01-02,2026-01-03,2026-01-04" ["price"]=> string(3) "120" } [9]=> array(3) { ["name"]=> string(16) "Spring half-term" ["days"]=> string(109) "2026-02-20,2026-02-21,2026-02-22,2026-02-23,2026-02-24,2026-02-25,2026-02-26,2026-02-27,2026-02-28,2026-03-01" ["price"]=> string(3) "100" } [10]=> array(3) { ["name"]=> string(6) "Easter" ["days"]=> string(197) "2026-04-02,2026-04-03,2026-04-04,2026-04-05,2026-04-06,2026-04-07,2026-04-08,2026-04-09,2026-04-10,2026-04-11,2026-04-12,2026-04-13,2026-04-14,2026-04-15,2026-04-16,2026-04-17,2026-04-18,2026-04-19" ["price"]=> string(3) "100" } [11]=> array(3) { ["name"]=> string(7) "May Day" ["days"]=> string(43) "2026-05-01,2026-05-02,2026-05-03,2026-05-04" ["price"]=> string(3) "110" } [12]=> array(3) { ["name"]=> string(16) "Summer half-term" ["days"]=> string(109) "2026-05-22,2026-05-23,2026-05-24,2026-05-25,2026-05-26,2026-05-27,2026-05-28,2026-05-29,2026-05-30,2026-05-31" ["price"]=> string(3) "110" } [13]=> array(3) { ["name"]=> string(6) "Summer" ["days"]=> string(516) "2026-07-17,2026-07-18,2026-07-19,2026-07-20,2026-07-21,2026-07-22,2026-07-23,2026-07-24,2026-07-25,2026-07-26,2026-07-27,2026-07-28,2026-07-29,2026-07-30,2026-07-31,2026-08-01,2026-08-02,2026-08-03,2026-08-04,2026-08-05,2026-08-06,2026-08-07,2026-08-08,2026-08-09,2026-08-10,2026-08-11,2026-08-12,2026-08-13,2026-08-14,2026-08-15,2026-08-16,2026-08-17,2026-08-18,2026-08-19,2026-08-20,2026-08-21,2026-08-22,2026-08-23,2026-08-24,2026-08-25,2026-08-26,2026-08-27,2026-08-28,2026-08-29,2026-08-30,2026-08-31,2026-09-01" ["price"]=> string(3) "120" } [14]=> array(3) { ["name"]=> string(16) "Autumn half-term" ["days"]=> string(120) "2026-10-23,2026-10-24,2026-10-25,2026-10-25,2026-10-26,2026-10-27,2026-10-28,2026-10-29,2026-10-30,2026-10-31,2026-11-01" ["price"]=> string(3) "110" } [15]=> array(3) { ["name"]=> string(10) "Christmas " ["days"]=> string(186) "2026-12-18,2026-12-19,2026-12-20,2026-12-21,2026-12-22,2026-12-23,2026-12-24,2026-12-25,2026-12-26,2026-12-27,2026-12-28,2026-12-29,2026-12-30,2026-12-31,2027-01-01,2027-01-02,2027-01-03" ["price"]=> string(3) "120" } If the requested dates are present in the price array i then need to extract the price for each day to put into an array to calculate the total cost if(in_array($rested, $prices) { array_push($cost, $prices[]['price']; } echo array_sum($cost); I have tried for loops, for each loops, array_diff, array_intersect and anything else i could think of put cant get it to work properly. Any help would me much appreciated The code i have put isnt the exact code i have now as i have been trying all day and its changed every time i've tried something else. The code i have right now only adds 2 prices to the cost array even though there more than 2 dates in the requested dates Please Help!! Thanks in advance
-
I managed to sort it, my question was a bit misleading. I had a calendar that was only showing 1 booked date range but that was because i had used = instead of == so now it shows all bookings
-
I realised I should add…. I have actually also established that this is unlikely to be a php (or more generally a ‘dynamically created content’) issue. I tried converting some of my files into statically generated files, ie nothing to do with PHP. My XSL files were still not cached by the browser properly. So this issue right now actually seems unrelated to PHP. It’s some kind of inconsistency between browsers’ treatment of different file types.
-
Remilo9868 joined the community
-
marvia joined the community
-
Thank you @gizmola - appreciate your time to reply. Unfortunately don’t have a Mac, but will looked into getting some help with this and also the “tail” suggestion .
-
DigitizingBuddy joined the community
-
There are a few different ways to process the stats based on what game and mod you are running. The one that is giving me the error is based on savestate 1 which continues from the last saved game log file. Savestate 0 runs without errors, but processes every game log file all over again every time. This is the from the batch file I use to tun the stats: C:\xampp\php\php.exe -f "C:\xampp\htdocs\q3eplus.servequake.com\vsp.php" -- -l q3a-xp -p savestate 1 "D:\Quake III Arena\excessiveplus\logs\server_mp.log"
-
Suyadi's comment is factually accurate. The code expects the constant value LOG_READ_SIZE, and it is not defined. WIth that said, often utility applications come with instructions on how they should be configured, it looks like this might be the case for the application. Check instructions and see if there is a configuration file that needs to exist in a particular place. Many applications are distributed with a file with default settings that needs to be copied and renamed.
-
That means it's not defined anywhere on that file so PHP can't find it. My suggestion would be to raise this issue to the developer of that script as the developer seems forgot to define that constant in their code. Those LOG_READ_SIZE constant used to set the offset of the fseek() and we don't know how big he set those number. my wild guess is as big as the log file size, so: defined('LOG_READ_SIZE') or define('LOG_READ_SIZE', filesize($logfilePath)); $seekResult = fseek($parser->logFileHandle, -LOG_READ_SIZE, SEEK_CUR);
-
Invalid password when using password_verify
Suyadi replied to rwahdan1978's topic in PHP Coding Help
This is correct, the length of string produced by password_hash() with default algorithm (bcrypt, as of now) is always 60 characters. So if you do password_hash('mypassword', PASSWORD_DEFAULT); and your database column can only store less than 60 characters, it will be truncated with some error being thrown -
Lol, me too That should be: $sql = $pdoObject->prepare($qry); $result = $sql->execute(['exp' => null, 'email' => $myusername]); As the PDOStatement::execute only accept one parameter. Reference: https://www.php.net/manual/en/pdostatement.execute.php
-
Trying to use GLOB function to create gallery.
Suyadi replied to BluApple's topic in PHP Coding Help
HI, you can try to use glob() with the __DIR__ constant. For example: $currentDir = __DIR__; // this is your current directory So, if you want to scan images inside your sub-directory, let's say the 'gallery' directory, just do: $subDirectory = 'gallery'; $images = glob($currentDir . '/' . $subDirectory . '/*.{jpg,jpeg,gif,png,bmp,webp}', GLOB_BRACE); Check the result: print_r($images); -
$timezone = 'Asia/Jakarta'; // Change this $dbTime = '2025-04-26 20:30:00'; $dbTime = DateTime::createFromFormat('Y-m-d H:i:s', $dbTime, new DateTimeZone($timezone)); $now = new DateTime('now', new DateTimeZone($timezone)); print_r($dbTime->diff($now)); print_r($now->diff($dbTime)); Result: DateInterval Object ( [y] => 0 [m] => 0 [d] => 5 [h] => 2 [i] => 13 [s] => 10 [f] => 0.828 [invert] => 0 [days] => 5 [from_string] => ) DateInterval Object ( [y] => 0 [m] => 0 [d] => 5 [h] => 2 [i] => 13 [s] => 10 [f] => 0.828 [invert] => 1 [days] => 5 [from_string] => )
-
How to get the current time and add 10 minutes?
Suyadi replied to rwahdan1978's topic in PHP Coding Help
$timezone = 'Asia/Jakarta'; // Change this $date = new DateTime('now',new DateTimeZone($timezone)); $date->modify('+10 minute'); echo $date->format('Y-m-d H:i:s'); -
Trying to use GLOB function to create gallery.
BluApple replied to BluApple's topic in PHP Coding Help
Adding question marks helped! Silly me! 😧 Using barands code displays all picures on the smae page while i'm trying to create a folder. Http://inflorescence.infy.uk/tryout.php -
Trying to use GLOB function to create gallery.
BluApple replied to BluApple's topic in PHP Coding Help
The file is in the main folder where to upload the website. Let me try to use the correct inclusief code. That might help. I'll get back as soon as i've tried that.