Jump to content
Old threads will finally start getting archived ×

Leaderboard

Popular Content

Showing content with the highest reputation since 03/28/2024 in all areas

  1. the file system path/filename must be to where the file is located on the disk, either using a relative path (relative to the file with the include/require starting in it) or an absolute path. a leading / refers to the root of the current disk, which is doubtful where that file is located, and which will be producing a php error about a non-existent path/file. you must get php to help you by reporting and displaying all the errors it detects. you can temporarily set php's error_reporting/display_errors in your code (you will want to remove the settings when you are done learning, developing, and debugging). you can add the following immediately after the first opening <?php tag in the main file - ini_set('display_errors', '1'); error_reporting(-1);
    2 points
  2. I'd do something like this... <?php $data = [ '46.105.73.18:27015' => [ 'gq_address' => '46.105.73.18', 'gq_dedicated' => '', 'gq_gametype' => '', 'gq_hostname' => '', 'gq_joinlink' => 'steam://connect/46.105.73.18:27015/' , 'gq_mapname' => '', 'gq_maxplayers' => '', 'gq_mod' => '', 'gq_name' => 'Counter-Strike: Source' , 'gq_numplayers' => '', 'gq_online' => '', 'gq_password' => '', 'gq_port_client' => 27015 , 'gq_port_query' => 27015 , 'gq_protocol' => 'source' , 'gq_transport' => 'udp' , 'gq_type' => 'css' , 'players' => Array (), 'teams' => Array () ] ] ; $tdata = ''; foreach ($data as $k => $v) { $v = array_filter($v); // get rid of blank values $tdata .= "<table border='1'> <tr><th>Array key</th><th>" . join('</th><th>', array_keys($v)) . "</th></tr>\n"; // output headings $tdata .= "<tr><th class='rowth'>$k</th><td>" . join('</td><td>', array_values($v)) . "</td></tr> // output values </table>\n"; } ?> <html lang='en'> <head> <meta 'charset'='utf-8'> <title>Example</title> <style type='text/css'> table { border-collapse: collapse; margin-bottom: 10px; } th { background-color: #444; color: white; padding: 8px; } .rowth { background-color: #888; } td { padding: 8px; text-align: center; } </style> </head> <body> <?= $tdata ?> </body> </html> Giving ...
    2 points
  3. First step to manually parsing HTML is to stop manually parsing HTML. Use DOM instead.
    2 points
  4. After about 3 hours of waiting I killed the process as the SQL server never showed a status other than "idle". I think it hit a problem and got itself into an infinite loop doing nothing. To give myself some data to work with, I managed to extact the table structure , the first 3,400 and the last 600 records from the sql file. I could have done all of them but it (thankfully) uses multiple row inserts (1700 at a time) and it takes an age scrolling through the text to find each block's start and end then select the block. There are about 200 such blocks and each takes about 2.5 seconds to load the data - so the whole load should have taken 8-9 minutes. Enough of the excuses. I finally came up with a solution using the post table. The first part (WITH ...) creates a temporary table called "plast" which contains a row for each threadID with the latest date of all the posts for the thread. The main part of the query (SELECT ...) matches the threadid/latest date with the post table to find the matching post and also joins to the thread table to pick uo thread info. Finally, I limit the output to just those dates in the last 7 days. (Apologies for screwing up the text encoding along the way - eg "Jürgen Peters". It's only test data.) WITH plast AS ( SELECT threadID , MAX(time) as latest FROM wbb1_1_post GROUP BY threadID ) SELECT t.threadID , t.topic , p.userID , p.username , p.postid , FROM_UNIXTIME(p.time) AS time , FROM_UNIXTIME(plast.latest) AS latest FROM wbb1_1_post p JOIN wbb1_1_thread t ON p.threadID = t.threadID JOIN plast ON plast.threadid = p.threadid AND plast.latest = p.time WHERE FROM_UNIXTIME(p.time) > CURDATE() - INTERVAL 7 DAY ; +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ | threadID | topic | userID | username | postid | time | latest | +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ | 131549 | welche Spinne? --> eventuell Lepthyphantes sp. | 5455 | Manfred Zapf | 507256 | 2025-01-26 10:08:19 | 2025-01-26 10:08:19 | | 131698 | Baumwanze | 1397 | zobel | 507259 | 2025-01-26 12:48:43 | 2025-01-26 12:48:43 | | 56659 | Grüne Futterwanze? | 15196 | Christine | 507261 | 2025-01-26 14:57:09 | 2025-01-26 14:57:09 | | 131576 | Kleine schwarze Spinne --> Enoplognatha cf. thoracica | 15395 | Bernd 07 | 507263 | 2025-01-26 16:01:45 | 2025-01-26 16:01:45 | | 131307 | Amaurobius fenestralis? --> bestätigt | 15395 | Bernd 07 | 507264 | 2025-01-26 16:08:09 | 2025-01-26 16:08:09 | | 131701 | Unbekannte Schneckenart | 15395 | Bernd 07 | 507267 | 2025-01-26 16:43:50 | 2025-01-26 16:43:50 | | 131702 | Encyrtidae? | 11406 | JohnEs81 | 507268 | 2025-01-26 17:00:37 | 2025-01-26 17:00:37 | | 131700 | Welche Wanze ist das? --> Arocatus longiceps | 15395 | Bernd 07 | 507272 | 2025-01-26 17:36:02 | 2025-01-26 17:36:02 | | 131699 | Tegenaria --> nein sondern Amaurobius similis/fenestralis | 1999 | Klaus Fritz | 507274 | 2025-01-26 17:48:07 | 2025-01-26 17:48:07 | | 131683 | Grüne Larve -> Geometridae Art | 11406 | JohnEs81 | 507280 | 2025-01-26 20:41:49 | 2025-01-26 20:41:49 | | 131703 | eine Acericerus heydenii? | 1 | Jürgen Peters | 507282 | 2025-01-26 20:45:32 | 2025-01-26 20:45:32 | | 131687 | Zygina nivea? | 15392 | Sascha_N | 507286 | 2025-01-26 21:15:21 | 2025-01-26 21:15:21 | | 131686 | Welcher Schnellkäfer? --> Melanotus sp. | 15395 | Bernd 07 | 507287 | 2025-01-26 21:29:11 | 2025-01-26 21:29:11 | | 131693 | Lispocephala brachialis --> bestätigt | 15800 | Bernd Cogel | 507293 | 2025-01-26 22:06:16 | 2025-01-26 22:06:16 | | 131704 | Cantharis paradoxa? --> Cantharis sp., ein schwarzer, immerhin | 15335 | Simeon Indzhov | 507295 | 2025-01-26 22:29:15 | 2025-01-26 22:29:15 | | 131695 | Peyerimhoffina gracilis? | 15335 | Simeon Indzhov | 507296 | 2025-01-26 22:36:08 | 2025-01-26 22:36:08 | | 131705 | Phytoecia coerulescens? | 1 | Jürgen Peters | 507297 | 2025-01-26 22:52:48 | 2025-01-26 22:52:48 | +----------+----------------------------------------------------------------+--------+------------------+--------+---------------------+---------------------+ Are you planning on rebuilding the database?
    2 points
  5. you are doing 'date-ination'. it's like pagination, but using dates. you should be using a get request to determine what will be displayed on the page. this is so that if someone finds a result they would like to return to or share, they can bookmark or share the URL and can return to the same result. the dates you pass in the URL should be a standard YYYY-MM-DD format. format the dates as 'l j M' only when you display them. you would default to the current monday if there is no get input. you would produce the previous/next links with the previous/next monday's date and include any existing get parameters so that if you add other search/filters, they will automatically get propagated in the URL between pages. example code - <?php date_default_timezone_set('America/Denver'); // default to the current monday if there is no get input if(!isset($_GET['fdw'])) { $dw = new DateTime('monday this week'); $fdw = $dw->format('Y-m-d'); } else { // you should validate that the get input is a properly formatted date - code left up to you $fdw = $_GET['fdw']; } // use $fdw in your code to produce the output $dw = new DateTime($fdw); echo $dw->format('l j M') . '<br>'; // get a copy of any existing get parameters $get = $_GET; // produce the previous link // calculate previous date $dw = new DateTime($fdw); $pw = $dw->modify('-1 week'); $pfdw = $pw->format('Y-m-d'); // set the fdw element $get['fdw'] = $pfdw; // build the query string part of the url $qs = http_build_query($get,'','&amp;'); echo "<a href='?$qs'><button>< Previous Week</button></a>"; // produce the next link // calculate next date $dw = new DateTime($fdw); $nw = $dw->modify('+1 week'); $nfdw = $nw->format('Y-m-d'); // set the fdw element $get['fdw'] = $nfdw; // build the query string part of the url $qs = http_build_query($get,'','&amp;'); echo "<a href='?$qs'><button>Next Week ></button></a>";
    2 points
  6. It might work a little more cleanly in PHPStorm, but when I tried it in VS Code, I found it much more complicated to try to select text or read through code when the editor was injecting those things into the view. Maybe if they weren't inline, though I can't imagine how not, they might be nicer for me... But I'm also a proponent of the idea that you should be able to tell what the parameter is, be that through a variable name or an obvious literal value (or a constant...), and if you can't tell then you should do something about that. // this is obvious on what the parameters are password_verify($password, $hashedPassword) // this is not password_verify($value, $row[1])
    2 points
  7. Judicious application of array key names can greatly increase the efficiency and simplicity of your code. Consider this simplified version of the questions/options form code <form method='post' > <?php for ($qno=1; $qno<=2; $qno++) { echo <<<HTML <label> Sub Question $qno <span class="req">*</span> <textarea cols="46" rows="3" name="Q[$qno][question]" placeholder="Enter Sub question here.."></textarea> </label> <ul> HTML; for ($opt='A'; $opt<='D'; $opt++) { echo <<<HTML <li>Choice $qno$opt (text)&nbsp; <input type='text' name="Q[$qno][opts][$opt]" placeholder="Enter Choice A here.." size='40'> </li><br><br>\n HTML; } echo "</ul><hr>\n"; } ?> <input type='submit'> </form> producing... When the form is submitted, the POST array is like this... Array ( [Q] => Array ( [1] => Array ( [question] => aaaaaaaaaaaaaaaaaaaaaaaaaaa [opts] => Array ( [A] => aa [B] => bb [C] => cc [D] => dd ) ) [2] => Array ( [question] => bbbbbbbbbbbbbbbbbbbbbbbbb [opts] => Array ( [A] => ww [B] => xx [C] => yy [D] => zz ) ) ) ) Now you can easily iterate through the array to write the questions/options to you database foreach ( $_POST['Q'] as $qno => $qdata ) { write $qno and $qdata['question'] to question table save last insert id as $qid foreach ( $qdata['opts'] as $ono => $choice ) { write $qid, $ono, $choice to choice table } } Job Done.
    2 points
  8. Unchecked checkboxes are not posted. I prefer to use a the null coalescing operator (??) when handling checkboxes EG $Bold = $_POST['Bold'] ?? 0; //if not set, default to '0'
    2 points
  9. I had to create my own test data (thanks for that) but naturally I don't know how it conforms with yours. TABLE: product TABLE: bookingItem +----+-------------+-----------+--------+ +----+-----------+---------------------+---------------------+----------+ | id | productName | category | status | | id | productid | startTime | endTime | quantity | +----+-------------+-----------+--------+ +----+-----------+---------------------+---------------------+----------+ | 1 | Room 1 | Guestroom | Active | | 1 | 1 | 2024-01-01 11:32:01 | 2024-01-02 11:32:59 | 1 | | 2 | Room 2 | Guestroom | Active | | 2 | 2 | 2024-02-01 11:34:08 | 2024-02-03 11:34:24 | 2 | | 3 | Room 3 | Guestroom | Active | | 3 | 3 | 2024-03-01 11:34:56 | 2024-03-04 11:35:08 | 3 | | 4 | Room 4 | Guestroom | NULL | | 4 | 2 | 2024-04-01 12:20:20 | 2024-04-07 12:20:41 | 6 | | 5 | Room 5 | Guestroom | NULL | | 5 | 3 | 2024-05-01 01:21:49 | 2024-05-05 12:21:58 | 4 | +----+-------------+-----------+--------+ | 6 | 5 | 2024-06-19 12:23:03 | 2024-06-29 12:23:28 | 10 | | 7 | 2 | 2024-06-01 13:02:51 | 2024-06-15 13:03:16 | 14 | +----+-----------+---------------------+---------------------+----------+ On running your code with my data I get these results for Q1 and Q2. I have written the correct totals in red. As you can see there is a distinct pattern - your totals are the correct totals squared. However, I could not spot any multiplication in the code (I ran as separate query to confirm the correct totals) I have to say, in your code you really make a meal of those dates in the years and quarters considering that SQL can handle it easily. Here's my version... <?php ############################################### # CREATE YOUR OWN PDO DATABASE CONNECTION # # # require 'db_inc.php'; $pdo = mdbConnect('db1'); # # # # ############################################### $range = [ '2020-01-01', '2024-07-31' ]; $selectedYear = $_GET['year'] ?? 0; $whereYear = ''; if ($selectedYear) { $whereYear = 'AND YEAR(d.dt) = ?'; $range[] = $selectedYear; } $res = $pdo->prepare("WITH RECURSIVE dates(dt) AS ( SELECT ? UNION ALL SELECT dt + INTERVAL 1 MONTH FROM dates WHERE dt < ? ) SELECT YEAR(d.dt) AS yr , QUARTER(d.dt) as qtr , MONTHNAME(dt) AS mth , productName AS room , COALESCE(SUM(DATEDIFF(endTime, startTime)), '-') AS nights FROM product p CROSS JOIN dates d LEFT JOIN bookingitem b ON b.productid = p.id AND YEAR(d.dt) = YEAR(b.startTime) AND MONTH(d.dt) = MONTH(b.startTime) WHERE p.`status` = 'Active' $whereYear GROUP BY yr, qtr, MONTH(d.dt), p.id "); $res->execute($range); $results = $res->fetchAll(); $rooms = array_unique(array_column($results, 'room')); $theads = "<tr><th>Quarter</th><th>Month</th><th>" . join('</th><th>', $rooms) . "</th><th>Total</th></tr>\n"; ### RESTRUCTURE THE RESULTS ARRAY foreach ($results as $r) { $data[$r['yr']][$r['qtr']][$r['mth']][$r['room']] = $r['nights']; } ?> <!DOCTYPE html> <html lang='en'> <head> <meta charset="utf-8"> <title>Example</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> table { width: 100%; border-collapse: collapse; } th { background-color: #808080; color: white; padding: 8px; } td { padding: 4px 12px; text-align: right; } .ca { text-align: center; background-color: #EEE; } .la { text-align: left; background-color: #EEE; color: black; } </style> </head> <body> <header class='w3-indigo w3-padding w3-margin-bottom'> <h1>Guestroom Occupancy</h1> </header> <div class='w3-content w3-padding'> <?php ## OUTPUTFROM RESTRUCTURED ARRAY foreach ($data as $yr => $ydata) { echo "<h3>$yr</h3>\n <table border='1'> $theads "; foreach ($ydata as $qtr => $qdata) { $span = 3 + count($rooms); echo "<tr><th class='la' colspan='$span'>Quarter {$qtr}</th></tr>\n"; foreach ($qdata as $mth => $mdata) { echo "<tr><td>&nbsp;</td><td>$mth</td><td>" . join('</td><td>', $mdata) . "</td><td><b>" . array_sum($mdata) . "</b></td></tr>\n"; } } echo "</table>\n"; } ?> </div> </body> </html> Output
    2 points
  10. 2 points
  11. Hi No offense taken at all ; I was just annoyed at myself with the fact that I spent most of last night debugging something, that seemingly fixed itself next morning (as is often sadly the case) Thats propably why my reply seemed angry. I apologize. As for the actual problem I have no idea what caused the initial behaviour. Now I get perfectly reasonable results regardless of whether i use cURL or file_get_contents; I therefore thought it was fitting to mark your reply as the solution, since: was exactly what was needed. Best, David
    1 point
  12. There are issues here beyond the error you're seeing. First and foremost, drop mysqli_* and use PDO - it's easier to use and can handle several different SQL dialects. Secondly, never put raw user data into a query (session data can be modified by the user). Use prepared statements in order to not lose or expose your data. As to the actual issue you're seeing, print out the value of $Number and $MW before you run the query to make sure they contain what you think they contain. If the value is actually '55th' you need quotes around the value - another bonus of using prepared statements (preparing the statement will take care of that for you).
    1 point
  13. this doesn't exist at the point when the ajax request is made, because they are two different http(s) requests. that's because ALL the code in index.php has already been executed during the initial http(s) request for index.php, by the time the ajax request occurs. for the initial case when the session variable doesn't exist, after you output the javascript code, the php code needs to exit/die without doing anything else (it currently runs to completion.) the ajax request needs to be to index.php, instead of screenDetect.php. the code will then set the session variable and it will be available when the rest of the code in index.php runs.
    1 point
  14. Could be there is no data in the table for the last 7 days. Try "- INTERVAL 1 MONTH"
    1 point
  15. You don't need a separate table to specify the structure, your board table already contains the structure by virtue of the parentid column. Just needs a recursive function to resolve... include 'db_inc.php' ; $pdo = mdbConnect('jodunno'); // connect to database $res = $pdo->query("SELECT parentID, boardID, title FROM wbb1_1_board ORDER BY parentID, title"); $brds = []; foreach ($res as $r) { $brds[$r['parentID']][] = [ 'id' => $r['boardID'], 'title' => $r['title']]; } // echo '<pre>' . print_r($brds, 1) . '</pre>'; echo "<ul>\n"; outputBoard($brds, 0); echo "</ul>\n"; function outputBoard(&$brds, $parent) { foreach ($brds[$parent] as $b) { echo "<li>{$b['title']}</li>\n"; if (isset($brds[$b['id']])) { // if this is a parent board echo "<ul>\n"; outputBoard($brds, $b['id']); // recursively output the child boards echo "</ul>\n"; } } }
    1 point
  16. Thank you. You should know that i have a text file of data that you have posted. I always appreciate the wisdom from the top talent here at phpfreaks. I have learned alot from this forum and its top members. I give credit where credit is due. I actually learned how this JOIN is working and i have successfully implemented my own query on the db last night before bed. I'll post the code in a reply to Barry. My point is that i learn from Barry and not simply take code and be on my way. I'm not looking for a free ride, only help when something is above my current level of knowledge. I hope that you have a splendid day, Gizmola.
    1 point
  17. I'm sure he does know that, and we are both motivated by an interest in mentoring and passing along our expertise to people like yourself if we are able. We appreciate the feedback.
    1 point
  18. From what I have been given, I came up with this ... SELECT b.boardID , b.title , t.threadID , t.topic , t.userID , t.username , FROM_UNIXTIME(t.time) AS time , FROM_UNIXTIME(t.lastPostTime) AS lastPostTime FROM wbb1_1_board b JOIN wbb1_1_thread t USING (boardid) JOIN wbb1_1_board_last_post l USING (boardid, threadid) ORDER BY boardID, threadid, time; Hovever, it seems to me that there should be a "post" table containing the post details, including the time_posted. Then you could just extract the posts containing the latest timestamp for each thread.
    1 point
  19. Contact your hosting provider for assistance. In the meantime, you will need to upload your PHP file change by some other means, such as by using SFTP.
    1 point
  20. Earlier in this thread you said that this ... +----+-----------+-----------+ | id | slug | tag_check | +----+-----------+-----------+ | 1 | hugh-jass | 1 | | 2 | hugh-jass | 2 | +----+-----------+-----------+ ... was acceptable. Your "solution" would not permit this. Secondly, you are using a "dependent subquery" which means for every record inserted you must query all the existing lookig for a duplicate. This can be extremely slow and should be avoided when writing queries. Changing your unique key to ... UNIQUE INDEX `unq_name` (`name`) USING BTREE, ... and using this query would have same result ... INSERT IGNORE into wp_terms (name,slug) SELECT concat(nameFirst,' ',nameLast) , lower(concat(nameFirst,'-',nameLast)) FROM a_players ;
    1 point
  21. I get that you're saving yourself some effort, but when you tell people "I asked a question somewhere else, go see what it was and try to answer" it's typically going to be taken as an insult. But I'll answer anyway because it doesn't look very good. According to what I'm seeing in the Docker Hub page, there is no simple upgrade path once the PHP version is no longer supported. Normal Docker practices would allow it, but this image isn't set up to follow normal Docker practices. So you'll have to go into the container itself and update it manually - like if it was an actual computer running Alpine Linux and you needed to upgrade it. You can look around for instructions on how to do that. Which means you should reconsider how this all works. For example, you could convert your existing installation to the "Static image" one that's described in the docs... though you'll have to reverse-engineer some of that process in order to preserve the details of your existing setup. But once that process is done and you've converted to a static deployment, future upgrades seem like they would be as simple as updating image versions in your docker-compose. (And you would then do all updates that way - not from within WP itself.)
    1 point
  22. CodeIgniter 4 is leaps and bounds better than 3 - it was re-written from scratch to make use of modern development patterns. That being said, as gizmola mentioned it was still pretty bare-bones last time I used it, whereas Laravel is fully featured. Some may say too fully featured, but it's optimized very well and has a large and active ecosystem. For instance, if you don't want to pay for Pusher they just released Reverb, which is a Laravel-specific websocket package that isn't the easiest thing to set up, but once you do it's quite good. It has a robust queue system that allows the developer to do a lot of work asynchronously right out of the box. The learning curve is steep, but most frameworks have that problem. Just know going in that there is a lot of magic to Laravel, so making sure you're comfortable reading source code is important (although the docs are better than most, IMO). I've not used Symfony specifically but - again as gizmola says - Laravel is built heavily on Symfony components. Best bet is to try building something smallish in all three and see which sings to you. Personally, even recognizing that Laravel has plenty of warts I prefer to work in it (though that may be Stockholm Syndrome as I've been working with it almost exclusively for about 6 years now).
    1 point
  23. As an aside, you should evaluate re-building with Symfony. Laravel and Symfony are by far the best PHP frameworks at this point, and have many similarities. Both frameworks are Dependency Injection frameworks, so you want to spend some time getting comfortable with what DI is, and how you would utilize that pattern with the code you write. It also allows you to make use of things like autowiring and lazy loading (intelligently loading of classes when needed rather than kitchen sink loading of classes you might never use in a request) which will be handled by the framework for you, so long as you understand it. Codeigniter is a fine, but very old and basic framework that is bare and simple in complexity. Depending on the features of the app you may have had to write your own code to implement features that either of these frameworks may have provided support for. They are also built upon component libraries so there is a bit of mixing and matching you'll see, as for example some Laravel developers prefer Symfony's twig templating system, and will integrate that instead of Laravel's Blade. I personally prefer the Doctrine ORM for working with relational database code, as it's designed around the "Data Mapper" pattern, rather than Active Record, which is what Laravel Eloquent uses. In either case, CI doesn't come with an ORM so that is new territory. You don't have to convert to the use of an ORM, but in most cases you will want to. Scalability is achieved through architecture. No monolithic framework is scalable. With that said you have to make decisions as to how you will achieve scalability. As both Symfony and Laravel have been used to develop high traffic consumer sites and applications that are architected to support high transaction rates and the features you listed, there is ample support for implementing scalable architecture. On the flip side, experience in these areas is harder to come by, and entire books have been written. These days scalability of required infrastructure typically involves the expertise of DevOps engineers who along with developers are creating deployment infrastructure and features that allow for this scalability. For example, one of the first issues one can hit (outside of an uncached database that has too much data and too many queries hitting it) is having enough frontend application servers to handle the request load. So you need frontend application code that was designed to be 1 - of - N, and that was not designed or configured with a monolithic configuration. The simplest example of this is the question of session. Using PHP sessions, the session files will by default be written to disk. When user requests exceed the capacity of a single server what do you do? Let's say you add a second server now. This requires some form of load balancing or reverse proxying. How do you handle sessions then? There are a variety of approaches you can take architecturally. The code will likely be the same, but configuration may need to be different to allow for scalability. As for security, both Symfony and Laravel have been built with security in mind, and have features that encourage and support it. With that said, one can always go around best practices or features that enable additional security. If however, you work with what the frameworks provide you have a solid foundation. Chat: Can be done different ways, but HTTP is inherently not designed for long running persistent socket connections. Websockets is the leading alternative to support this, but it requires separate infrastructure. For that reason, Platform as a service PAAS companies like Pusher exist to support this. You could also self host something like a Mercure server (see https://mercure.rocks/) or you could use a company like Pusher (https://pusher.com/websockets/). Both Symfony and Laravel have community support options (component libraries) that make working with these websocket wrapper platforms, and have been used by many companies. There is also Twilio which provides both text messaging and general messaging api's that can be used as well as telephony features like masked calling. I feel like I'm getting far afield here, but I've worked on several projects for a consumer service company that made extensive use of Twilio, although that company was profitable and well funded, so the inherent costs were the subject of contract negotiations and not a concern at the time. Pusher and hosted Mercure both have free development tiers and in my opinion are reasonably priced when you consider the costs you would incur to self host this additional infrastructure, so that is what I would recommend. This should also tell you a lot about the possibility and the need for architectural planning and building to it. Again I can only say that Symfony and Laravel have been used to create services and the backend for applications that serve large numbers of simultaneous users, while offering asynchronous processing of messaging, email etc. Yes, although Symfony has a release process that offers LTS. See https://symfony.com/doc/current/contributing/community/releases.html With Laravel the window is 12 months (24 for security releases) so to be completely supported, you are looking at a fairly constant cycle of at very least minor version upgrades. See https://laravelversions.com/en My last comment on Laravel: What many people like about Laravel is that it has facades. Initially facades are attractive to new developers because they are "magical" and appear to make things simple. They are a foundation for Laravel and probably one of the reasons it gained rapid popularity. Essentially, what laravel facades do is add glue that makes any class look like its public methods are static, when in fact, this is an illusion and glue code that is part of Laravel. You can read more about Facades here: https://laravel.com/docs/11.x/facades As I mentioned earlier, Laravel and Symfony are both Dependency Injection frameworks, so Facades are something different, as they plainly discuss in their documentation. In practical use, facades and associated "helper" functions are ways to just use services that are built into Laravel. So it encourages one not to use Dependency Injection, which makes the code less maintainable, and also harder to write tests for because you can't mock the parameters. If you read the facades page you'll notice that their answer for this is that facades have a built-in method to get around this issue, so you basically have to write a test that works around the way you would have written the test if you just used the DI pattern and a constructor parameter in the first place. So in their documentation they have this example where a Route handler (also a facade being used here, but nevermind that) is in the first example, returrning a Response object using the json() method, and then an example using this global "helper" function "response()->json". use Illuminate\Support\Facades\Response; Route::get('/users', function () { return Response::json([ // ... ]); }); Route::get('/users', function () { return response()->json([ // ... ]); }); So whipping something out fast, I guess might appeal to someone, because they don't need to understand the details of how this all works, although of course, every feature like this comes with a runtime cost. But the longer term question that has to be asked is: when you can write standard DI code, and just not use facades or helpers, and that makes understanding code easier, and writing tests easier, why not do that instead. Since Symfony doesn't have facades, it is not something you ever would concern yourself with, although you can just use Laravel and inject the parameters. The reality is that if you go with Laravel, you will be encouraged through the documentation to make use of facades and or helper functions, and you should know that going into the project.
    1 point
  24. If you're asking, does that mean you tried what I said and couldn't find an answer and decided to not mention that? Or does it mean you saw my answer and decided you didn't like it and wanted something else instead?
    1 point
  25. You only need one query. For example TABLE : product +----+-------------+--------------+--------+ | id | productName | category | status | +----+-------------+--------------+--------+ | 1 | Room 1 | Guestroom | Active | | 2 | Room 2 | Guestroom | Active | | 3 | Room 3 | Guestroom | Active | | 4 | Room 4 | Guestroom | Active | | 5 | Function 1 | Functionroom | NULL | +----+-------------+--------------+--------+ code $sql = "SELECT SUM(status='Pending')as pending , SUM(status='Active') as active FROM product"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); echo "Pending : <input type=\"button\" class=\"button\" value=\"{$row['pending']}\"> Active : <input type=\"button\" class=\"button\" value=\"{$row['active']}\"> "; output
    1 point
  26. I'm not well versed in using cURL, but based on what you provided previously your call to the URL you are using is returning the response: 301 error "Permanently Moved" But, you expect to be getting the JSON encoded output for the $allowed_domains array you are creating. I would assume you have tested the url in a browser and verified you are seeing the JSON content? If not, start there. If the content is correct when access via a browser then my best guess is that the web server maybe has some logic to detect programmatic access to pages and is blocking it. I'm pretty sure I've seen something like that before. But your issue has noting to do with the error you first reported. You need to figure out why your cURL request is not retrieving the JSON content you think it should be returning. Although, this is a good opportunity to add additional error handling to your code to cover a scenario where the cURL request doesn't fail, but does not return contents you expect.
    1 point
  27. Hello folks! I am new here. Nive to join the community.
    1 point
  28. There is an example near the end of the documentation for last_insert_id. Something like this I am guessing. $sql = " UPDATE $table SET item=?, id=LAST_INSERT_ID(id) WHERE id<10 ORDER BY id ASC LIMIT 1; "; //and then $last_id = mysqli_insert_id($conn); echo "Last inserted ID is: " . $last_id;
    1 point
  29. I feel like there's an echo in here.
    1 point
  30. Are you still with us? requinix is a pro. You are in good hands. Meantime, margins is interesting because do you want margins or not? I see a double break after the body tag. <body><br><br/> incidentally, html5 does not require the ending slash. vide xhtml. since you are already using css, why not add margin control? <span style="font-family:'Comic Sans MS', Comic, Monospace; margin: 8px 8px"> the center tag is deprecated, is it not? Again, why not use css? align: center; text-align: center; let us know if you need further assistance. I will also post the entire script from the google drive link. I hope that it is okay to do so. Please forgive me if it is not okay to post the aftenrenlille.php code. <?php ini_set('default_socket_timeout', 5); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AU-INFO</title> <style type="text/css"> #dagensret{ //font-size:10px; } .food{ // color: green; font-size:15px; } </style> </head> <body><br><br/> <span style="font-family:'Comic Sans MS', Comic, Monospace"> <center> <span style="font-size:25pt"> <?php // 11 // remember to remove the ; from the beginning of extension=php_soap.dll in php.ini $cli= new SoapClient('https://xxxxxxxxxxx.dk/SPService.asmx?WSDL'); //$res = $cli->__soapCall('DagensMenu',array()); // $xmlstr = $res->DagensMenuResult->any; $simple = simplexml_load_string($xmlstr); $text = $simple->Menu->Tekst; echo "AFTENRENGØRING "; echo $text.""; ?> <!--Overskrift--> <span style="font-size:10pt"> <!--Overskrift--> <!--Vegatare--> <span style="font-size:25pt"> <!---> <?php $simple = simplexml_load_file('https://xxxxxxxxxxx/SPService.asmx/AktuelleOmraadeRengoering'); $text = $simple->Aktivitet->Navn; // slette + tegn AU $text = str_replace('+', '', $simple->Aktivitet->Navn); echo $text; ?> </body> </html> <!--Menu herover--> </html>
    1 point
  31. PHP runs on the server. - Javascript runs on the client. On completion of the PHP it sends the page to the client where the javascript runs. At the time you "echo $array;" the js variable "i" does not yet exist. (Error thrown if turn on error reporting) By the time the javascript runs "$array" no longer exists.
    1 point
  32. XHTML? No, this is just regular HTML... <header> elements are HTML 5 replacements to writing stuff like <div class="header">, which means things like browsers and screen readers can more accurately understand the nature of a page. That means they're geared towards content, not metadata. Which means they belong in the document body. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header
    1 point
  33. Answers to my questions would be nice too. "ftpd" is very likely going to be an FTP server. If you need it then you should look into what's wrong, if you don't then you can shut it down. It kinda sounds like the http and https sides are running with different user credentials. Except that's weird.
    1 point
  34. the attached code doesn't produce a php syntax error. there are only 270 lines. any chance you made a change and didn't save the file before trying to execute it? btw - addslashes() should never have been used with database code.
    1 point
  35. Which field in Charters identifies the driver in question? SELECT chtr.id, chtr.charter_name, chtr.fleet_number, chtr.driver, chtr.customer_name, chtr.customer_number, chtr.dep_date, chtr.status /* \/ \____/ Which of these is the id into the users table? */ , usr.id, usr.fname FROM charters AS chtr LEFT JOIN users AS usr ON chtr.id = usr.id /* \/ Should this, perhaps, be chtr.driver? */ I would expect every table to have its own, unique id field and those ids are completely independent of one another (by which I mean Charter .id=6 is a completely different thing to Users .id=6). Regards, Phill W.
    1 point
  36. The assignment operator is "=", not "==". Instead of the for() loop, why not just use in_array() as I did? function GetColour($Balls,$Ball) { return in_array($Ball, $Balls) ? "#0000ff" : "#c53ba1"; }
    1 point
  37. If you "fixed it" but it doesn't work then you didn't fix it. That input type=file can work, I would think, however it will require changing some number of other things - I can't say exactly what since it's complicated and it will depend a lot on other things (which you haven't shown) but it can work. Either that, or go back to what you had before and do what I originally said about using Javascript to prevent the form from being submitted. Again, I can't say exactly how since it depends on things you haven't posted, but the principle is very simple: when the form is being/is about to be submitted, check that there is a value for that cover "file", and if not then stop the form from submitting and tell the user they missed a step.
    1 point
  38. If you've fixed it then you don't need Javascript...
    1 point
  39. Set your old timestamp variable to null when the game is started/restarted. this.oldTimeStamp = null; Then in your game loop function, check if it's null and if so store the provided timestamp. if (this.oldTimeStamp===null){ this.oldTimeStamp=timeStamp; } This way your game always starts out at 0 for seconds passed. Currently, your first iteration when the page loads is essentially random as it depends on how long it takes for the browser to run the first game loop after starting the page.
    1 point
  40. as far as i can tell, mpdf doesn't support writing-mode or text-orientation - https://mpdf.github.io/css-stylesheets/supported-css.html the only reason you have a case where the letters are vertical is because there's only horizontal space in the layout for a single letter at that point. i recommend that you just add a <br> tag between each letter using code.
    1 point
  41. When it encounters the "<p>" it is still in the php section of the code and the "<p>" isn't valid php code. You need to exit from php before you enter the html. Move the "?>" line ...
    1 point
  42. Again, with svg we can add the text shadow and letter spacing <div style='background-color: black; text-align: center;'> <svg width='380' height='80' viewBox='0 0 380 80'> <defs> <style type='text/css'> .olap { font-family: "arial black"; font-size: 60pt; letter-spacing: -15px; fill: #fff; text-shadow: -0.08em 0.03em 0.12em rgba(0, 0, 0, 0.7); } </style> </defs> <text class='olap' x='190' y='70' text-anchor='middle' >OVERLAP</text> </svg> </div>
    1 point
  43. I actually use XSLT for some stuff at home: got a lot of data, I manage most it in XML with some in JSON because a real NoSQL database would be awkward to hand-edit like I need, and want to render it into a viewable form. Add XSLT and throw in PHP's function bindings and you can do just about anything. Downside: super inefficient, so complicated processing takes a while. Early 2000s, give or take, I even experimented with a XML-based website - as in the server responded with XML, not HTML. It worked very well. In fact, after getting back into it for the above project stuff, I'll very likely do it again for a couple smaller projects. Because the simplicity of editing data in XML lets me do whatever I want without having to run a database server or make table schema changes or build CRUD tools.
    1 point
  44. Another option, maybe Create question in MSWord Save page as html doc Display it in an <iframe> on your page
    1 point
  45. Some example code for you // INPUT DATES $col1 = '28/Apr/24 11:50 AM'; $col2 = '29/Apr/24 5:29 PM'; // FORMAT DEFINITIONS $jira = 'd/M/y h:i a'; $SQLformat = 'Y-m-d H:i:s'; $dt1 = DateTime::createFromFormat($jira, $col1); // create DateTime object $dt2 = DateTime::createFromFormat($jira, $col2); $d = $dt1->diff($dt2); // create DateInterval object echo $dt1->format($SQLformat) .'<br>'; // output dates echo $dt2->format($SQLformat) .'<br>'; printf("%d days %d hr %d min", $d->days, $d->h, $d->i); // show difference Output... 2024-04-28 11:50:00 2024-04-29 17:29:00 1 days 5 hr 39 min
    1 point
  46. We want to add a new element to the $cpa array in each call to the function. To do this we need always to add to the original empty array. The ampersand allows us to to this. Without it, a copy of the array would be passed to the function and we would just keep adding to a new empty array each time. &$cpa passes the array by reference (ie its address in memory) instead of a copy. P.S. This method below (which stores all the category data into a $cat_data array instead of running a query in every call to the function, is 5x faster. $cat_data looks like this... Array ( [532] => Array ( [name] => Motorbikes::1 [parent] => 0 ) [533] => Array ( [name] => Cars::2 [parent] => 0 ) [534] => Array ( [name] => Boats::3 [parent] => 0 ) [535] => Array ( [name] => Bicycles::4 [parent] => 0 ) . . . ) CODE $cat_data = []; $res = $pdo->query("SELECT id , CONCAT(name, '::', position) as name , parent FROM category "); foreach ($res as $r) { $cat_data[$r['id']] = [ 'name' => $r['name'], 'parent' => $r['parent'] ] ; } $category_path_array = []; retrieve_category_path ($cat_data, 552, $category_path_array); $breadcrumbs = join('/', $category_path_array); echo $breadcrumbs; function retrieve_category_path (&$cats, $id, &$cpa) { array_unshift($cpa,$cats[$id]['name']); if ($cats[$id]['parent']) { retrieve_category_path($cats, $cats[$id]['parent'], $cpa); } } Thank you - much appreciated.
    1 point
  47. After calling your recursive array you need finish up with a single array - you output a separate array during each iteration. Don't connect to db inside functions - it's the slowest part of the process and inefficient (plus you can quickly reach your connctions limit). Connect once then pass the connection to the functions. Don't include the separator in you results - add that when you implode (join). (Sorry for any delay - it's not easy to load an image of data into a database test table) My method... function retrieve_category_path($pdo, $id, &$cpa){ // DB connection // Company ID $stmt = $pdo->prepare("SELECT CONCAT(name, '::', position) as name , parent FROM category WHERE id = ? "); $stmt->execute([$id]); while($row=$stmt->fetch()){ $parent =$row['parent']; $name = $row['name']; $cpa[] = $row['name']; // append into array if($row['parent'] > 0){ retrieve_category_path($pdo, $row['parent'], $cpa); } } } $category_path_array = []; retrieve_category_path($pdo, 552, $category_path_array); $breadcrumbs = join('/', array_reverse($category_path_array)); echo $breadcrumbs; // Cars::2/Sports cars::1/Petrol::1/2 Door::0
    1 point
  48. I suggest output like this below. I have used yiur two resources and ny booking data looke like this... mysql> select * from booking; +----+-------------+---------------------+---------------------+ | id | resource_id | book_start | book_end | +----+-------------+---------------------+---------------------+ | 1 | 1 | 2024-05-13 09:00:00 | 2024-05-13 12:00:00 | | 2 | 1 | 2024-05-15 09:00:00 | 2024-05-15 19:00:00 | | 4 | 1 | 2024-05-16 12:00:00 | 2024-05-16 18:00:00 | | 5 | 2 | 2024-05-13 12:00:00 | 2024-05-17 18:00:00 | +----+-------------+---------------------+---------------------+ The output looks lke this for the 2 resources... CODE <?php require 'db_inc.php'; // $pdo = mdbConnect('db1'); // USE YOUR OWN CONNECTION CODE $wkcomm = $_GET['wkcomm'] ?? date('Y-m-d'); $resid = $_GET['resid'] ?? ''; ################################################################################ ## COLUMN HEADINGS ################################################################################ $d1 = new DateTime($wkcomm); $di = new DateInterval('P1D'); $dp = new DatePeriod($d1, $di, 6); $theads = "<tr class='w3-dark-gray'><th>Time Slot</th>"; foreach ($dp as $d) { $theads .= "<th>" . $d->format('D M d') . "</th>"; } $theads .= "</tr>\n"; ################################################################################ ## QUERY BOOKINGS AND BUILD ARRAY IN REQUIRED STRUCTURE FOR OUTPUT ################################################################################ $res = $pdo->prepare("-- -- create temporary table containing the dates of the selected week -- WITH RECURSIVE dateslot (n, slotdate) AS ( SELECT 1, ? UNION ALL SELECT n+1 , date_add(slotdate, INTERVAL 1 DAY) FROM dateslot WHERE n < 7 ), -- -- create temporary table containing the daily 30-minute timeslots -- timeslot (n, starttime, endtime) AS ( SELECT 1, '07:00:00', '07:30:00' UNION ALL SELECT n+1 , addtime(starttime, '00:30:00') , addtime(endtime, '00:30:00') FROM timeslot WHERE n < 24 ) SELECT slotdate , time_format(starttime, '%H:%i') as time , b.id -- -- cross join the two temporary tables to give rows for every timeslot for the seven days -- then match these against the bookings to see which slots fall withing the booking range -- for the selected resource -- FROM dateslot d CROSS JOIN timeslot t LEFT JOIN booking b ON CONCAT(d.slotdate, ' ', t.starttime) < b.book_end AND CONCAT(d.slotdate, ' ', t.endtime) > b.book_start AND b.resource_id = ? ORDER BY starttime, slotdate "); $res->execute([ $wkcomm, $resid ]); $data = []; foreach ($res as $r) { $data[$r['time']][$r['slotdate']] = $r['id']; } ################################################################################ ## LOOP THROUGH ARRAY TO CREATE HTML ROWS ################################################################################ $tdata = ''; foreach ($data as $tslot => $slotdata) { $tdata .= "<tr><td class='w3-gray w3-text-white'>$tslot</td>"; foreach ($slotdata as $booked) { $class = $booked ? 'w3-red' : ''; $tdata .= "<td class='$class'>&nbsp;</td>"; } $tdata .= "</tr>\n"; } ################################################################################ ## FUNCTIONS ################################################################################ function resourceOptions($pdo, $current) { $res = $pdo->query("SELECT id, description FROM resource ORDER BY description "); $opts = "<option value=''>- select resource -</option>\n"; foreach ($res as $r) { $sel = $r['id']==$current ? 'selected' : ''; $opts .= "<option $sel value='{$r['id']}'>{$r['description']}</option>\n"; } return $opts; } ?> <!DOCTYPE html> <html lang='en'> <head> <meta charset="utf-8"> <title>Example</title> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> table { border-collapse: collapse; width: 100%; } th, td { padding: 4px; } th { border: 1px solid white; } </style> </head> <body> <header class='w3-indigo w3-padding'> <h1>Resource Bookings</h1> </header> <form class='w3-light-gray w3-padding w3-margin-bottom'> Week commencing: <input type='date' name='wkcomm' value='<?=$wkcomm?>'> &emsp; Resource: <select name='resid'> <?=resourceOptions($pdo, $resid)?> </select> <button class='w3-blue w3-button'>Refresh</button> </form> <div class='w3-content'> <table class='w3-small' border='1'> <?=$theads?> <?=$tdata?> </table> </div> </body> </html>
    1 point
  49. Using filter_input_array with FILTER_SANITIZE_FULL_SPECIAL_CHARS for both $_GET and $_POST can provide an additional layer of security by sanitizing input data. However, keep in mind that it may cause unintended behavior if applied indiscriminately to all input. It's generally considered safe, especially when combined with htmlspecialchars, but ensure it doesn't interfere with any specific requirements or data types in your application. Best Regard Danish Hafeez | QA Assistant ICTInnovations
    1 point
  50. I don't know what you were doing in those screenshots but it sure doesn't look like you tried running "python app.py".
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.