Jump to content
  • Who's Online   0 Members, 1 Anonymous, 608 Guests (See full list)

    • There are no registered users currently online

All Activity

This stream auto-updates

  1. Today
  2. Yesterday
  3. Reconcile what? If you output the message before the pause then you see the message before the pause, and if you output the message after the pause then you see the message after the pause...
  4. while zero is a valid number, it should have never been used as a data identifier. any chance you can go through and change to use the next higher unused id? this could be anything from redirects without exit/die statements through to the database (strict) mode. this could even be due to obsolete html markup interacting with the latest version of a browser. if you cannot determine the cause of the problem, you will need to post all the code, less the database credentials, needed to reproduce the problem. you state this reverts to the home page. what exactly does that mean, ap/index.php? you could be seeing the result of the last of multiple page requests/redirects, i.e. it could have displayed the expected output, but then redirected to the 'home page'.
  5. Please post your code in a code block so we can see what is actually going on. We can sit and guess all day without seeing your code.
  6. Well, obviously, something has changed. We have no access to the code, the web server, etc. I have provided a "best guess" based on the only piece of information provided: team id is 0. I still think the most likely cause is something due to the value being the value zero. As to not seeing any errors, what level of error reporting do you have enabled. In a production environment, most errors should be suppressed. Have you even inspected the page viewTeam.php (and any included pages) to look at the code? Have you added any debugging logic to see where in the execution the logic is failing to do what you expect?
  7. Hi all. I'm not getting any errors. My page just reverts to my home page. Now this .php?t=0 has been working for more than a dozen years without fail. My PHP version is: PHP Version 7.0.33 There have been no changes to this page in years. Not sure why this fails the past few months.
  8. Many say that is not recommended to print (text, data, info...) in a function/method, because it makes it difficult to test (unless inelegant stratagems are used). Here's a demonstration $ cat FileTest.php <?php function copyFileExample($echoOutput) { $verboseText = "Copying file... please wait...\n"; if ($echoOutput) echo $verboseText; /* * since it is an example, instead of copy(), * the sleep(5) function is used, to simulate copying a file, * which let's pretend it takes 5 seconds */ sleep(5); // replaces copy() function if (!$echoOutput) return $verboseText; } class FileTest extends PHPUnit\Framework\TestCase { static function copyProvider() { return [ [ "echoOutput" => true // not recommended [HIGHLIGHT] ], [ "echoOutput" => false // recommended [HIGHLIGHT] ], ]; } /** * @dataProvider copyProvider */ function testCopy($echoOutput) { $this->assertEquals( "Copying file... please wait...\n", copyFileExample($echoOutput) ); } } I highlight some parts $ grep HIGHLIGHT FileTest.php "echoOutput" => true // not recommended [HIGHLIGHT] "echoOutput" => false // recommended [HIGHLIGHT] So let's launch the tests $ phpunit FileTest.php PHPUnit 10.5.20 by Sebastian Bergmann and contributors. Runtime: PHP 8.1.2-1ubuntu2.17 Copying file... please wait... F. 2 / 2 (100%) There was 1 failure: 1) FileTest::testCopy with data set #0 (true) Failed asserting that null matches expected 'Copying file... please wait...\n '. FileTest.php:37 FAILURES! Tests: 2, Assertions: 2, Failures: 1. As you can see, one of the two tests fails (the one in which true is given for the parameter), for the reason above. For the other test, however, nothing is reported, so it means that it's fine, but... but... but... all of this hides an irregularity. I don't know if I'll be able to explain it.... In practice, if you run copyFileExample(echoOutput: true); // BAD PRACTICE (difficult to test output), BUT GOOD RESULT "Copying file... please wait..." is displayed the process stops for 5 seconds (pretending to copy some file) the process ends normally Instead if you execute echo copyFileExample(echoOutput: false); // GOOD PRACTICE, BUT... the process stops (hangs) for 5 seconds: it seems to have frozen, no output... but then suddenly it says "Copying file... please wait..."; when in reality the waiting is already over (there is nothing left to wait for): the time sequence is not respected So is there a way to reconcile the two?
  9. On the subject of "loose typing of variables", version 8 of PHP is stricter than earlier versions. It could be that be that the failure now is due to an upgrade to this version from an old version. What error messages are you getting?
  10. Without any code, there is no way to make any type of qualified assessment on what the problem is. But, I will venture a guess. PHP is a "loosely" typed language. That means that variables can be used as different types. For example, you can use a string variable "2" as an integer 2. My guess is that there is some condition in the code that tests to see if the team ID is valid (i.e. not false). But, because the integer zero is also interpreted as the Boolean False the test is failing. Here is some mock code of what I am talking about: if(isset($_GET['t'])) { $teamId = $_GET['t'] } else { $teamId = false; } if($teamId == false) { //Team ID is false, don't show the content } else { //Show the team content } A team ID of zero will result in the error condition. You could correct THAT scenario by using the identical condition of !==. But, there can be multiple scenarios where a zero is being misinterpreted and you would have to look at each one to determine what the correct solution would be. There is a reason that most (all) databases start at 1 as the initial primary ID. Assuming this is a primary key in the DB, I would suggest changing that team's ID to a new unique number and updating all associated data.
  11. You can do it SQL when you load the CSV data into MySQL using the STR_TO_DATE() function to reformat the dates // CSV INPUT $input = 'Tom DiCanari,28/Apr/24 11:50 AM,29/Apr/24 5:29 PM'; // create tete table $pdo->exec("CREATE TABLE IF NOT EXISTS test1 (name varchar(50), timefrom datetime, timeuntil datetime)"); // process the input $stmt = $pdo->prepare("INSERT INTO test1 (name, timefrom, timeuntil) VALUES (?, STR_TO_DATE(?, '%d/%b/%y %h:%i %p'), STR_TO_DATE(?, '%d/%b/%y %h:%i %p'))"); $data = str_getcsv($input); $stmt->execute($data); then mysql> SELECT name -> , timefrom -> , timeuntil -> , timestampdiff(MINUTE, timefrom, timeuntil) as mins_diff -> FROM test1; +--------------+---------------------+---------------------+-----------+ | name | timefrom | timeuntil | mins_diff | +--------------+---------------------+---------------------+-----------+ | Tom DiCanari | 2024-04-28 11:50:00 | 2024-04-29 17:29:00 | 1779 | +--------------+---------------------+---------------------+-----------+
  12. Hello all. I have a bit of a strange situation that I'm scratching my head about. I have a Sports website and I have a simple script on this website that has been working for dozens of years, which recently has decided not to work properly - for only team "0". When I run this webpage using this PHP script https://www.baltimorebeach.com/ap/viewTeam.php?t=2 this page works (as does all the other team pages) and this page does not https://www.baltimorebeach.com/ap/viewTeam.php?t=0 and I can't figure out why it is suddenly not working. It works with every other team except for team "0" which is my team. Anyone have any thoughts on this? Thanks for your assistance.
  13. 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
  14. ...What are you using to view the CSV file? edit: Nevermind, looks like it does use a localized format after all. Stupid Jira. For PHP, use date_parse_from_format() or DateTime's createFromFormat, using the "d/M/y h:i a" format. https://3v4l.org/NPZvF
  15. I am not storing them, Jira is storing them in this format. Export to Jira->CSV->Import to MySql.
  16. Step 1: stop storing them in a non-standard format and use DATETIMEs instead. There is no step 2. Seriously. Use a standard format and this problem, and very likely other problems you've had or are yet to have, will go away.
  17. col1 col2 28/Apr/24 11:50 AM 29/Apr/24 5:29 PM This is honestly an interesting sql project of mine(I can use node.js as well). This is how I'd solve this manually: 29/Apr/24 Will be converted to 29/Apr/24 And it'll be converted to 29/04/24 ( There'll be a lookup table for Apr->04 mapping) And the time will be converted 17:29 (no unit PM or AM) Then, I'll convert the col1 date to the similar format. 28/04/24 Then time to same format 24h format. And subtract it. But I can't make sql to do this as I've not much idea about SQL syntax. Can anyone help me? my alternative is using node.js
  18. To achieve the desired layout where the image and text columns switch order on smaller screens, you can use CSS Flexbox with media queries. The key is to set the flex direction to column and change the order of the elements within the media query. <div id="flex"> <div id="left"> <img src="image.jpg" alt="Image"> </div> <div id="right"> <p>Your text goes here.</p> </div> </div> Default Styles for Larger Screens: By default, the elements will be displayed side by side (e.g., using Flexbox or Grid). #flex { display: flex; } #left, #right { flex: 1; /* or you can use a specific width like flex: 0 0 50%; */ } #left { order: 1; } #right { order: 2; } Use a media query to change the flex direction to column and adjust the order of the elements. @media only screen and (max-width: 950px) { #flex { display: flex; flex-direction: column; } #left { order: 2; } #right { order: 1; } } display: flex;: Ensures that the parent container uses Flexbox. flex-direction: column;: Stacks the child elements vertically instead of horizontally. order: Adjusts the order of elements. Lower values appear first. In the media query, setting #left to order: 2 and #right to order: 1 swaps their positions. here is complete example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Layout</title> <style> /* Default Styles for Larger Screens */ #flex { display: flex; } #left, #right { flex: 1; } #left { order: 1; } #right { order: 2; } /* Styles for Smaller Screens */ @media only screen and (max-width: 950px) { #flex { display: flex; flex-direction: column; } #left { order: 2; } #right { order: 1; } } </style> </head> <body> <div id="flex"> <div id="left"> <img src="image.jpg" alt="Image" style="width: 100%;"> </div> <div id="right"> <p>Your text goes here.</p> </div> </div> </body> </html> Best Regard Danish Hafeez | QA Assistant ICTInnovations
  19. Since PHP 8.3 may have stricter error reporting or handling compared to 8.3.6, this issue might have been silently ignored or handled differently in the previous version. To fix this issue, you should ensure that $forum_id is always set and not an empty string before trying to access $forums['f'][$forum_id]. You can also add a check to make sure the key exists in the array. foreach ($allowed forums as $forum_id) { if (empty($forum_id)) { // Skip this iteration if $forum_id is empty continue; } if (isset($forums['f'][$forum_id])) { $f = $forums['f'][$forum_id]; } else { // Handle the case where $forum_id is not found in $forums['f'] $f = []; // or set a default value, or log an error } $cat_forum['c'][$f['cat_id']][] = $forum_id; if ($f['forum_parent']) { $cat_forum['subforums'][$forum_id] = true; $cat_forum['forums_with_sf'][$f['forum_parent']] = true; } } Check for the existence of the array key using array_key_exists(): foreach ($allowed forums as $forum_id) { if (empty($forum_id)) { // Skip this iteration if $forum_id is empty continue; } if (array_key_exists($forum_id, $forums['f'])) { $f = $forums['f'][$forum_id]; } else { // Handle the case where $forum_id is not found in $forums['f'] $f = []; // or set a default value, or log an error } $cat_forum['c'][$f['cat_id']][] = $forum_id; if ($f['forum_parent']) { $cat_forum['subforums'][$forum_id] = true; $cat_forum['forums_with_sf'][$f['forum_parent']] = true; } } Check for Empty $forum_id: Ensuring $forum_id is not empty helps prevent accessing array keys with empty values. isset() and array_key_exists(): Both functions ensure that the key exists in the array before accessing it. isset() also checks that the value is not null, whereas array_key_exists() strictly checks for the presence of the key regardless of its value. Best Regard Danish Hafeez | QA Assistant ICTInnovations
  20. Last week
  21. For certain needs I want to use it; for others not. Instead of uninstalling and reinstalling it, I wanted to know if there is a way to turn it off, or rather, among those I proposed, which is the most correct one (or if both are equivalent). Nothing more, nothing lessexit!!!
  22. If you don't want to use the extension then don't install it 😕
  23. And to avoid loading the extension? There are those who suggest giving the command $ phpdismod xdebug There are those who suggest (for those like me who have Ubuntu 22.04.4) to open the file /etc/php/8.1/cli/conf.d/20-xdebug.ini and comment the line ;zend_extension=xdebug.so inserting ';' at the beginning And there are those who suggest other oddities, that I don't want to implement so as not to cause damage. Everyone has their say, but what is the correct, safe and official method?
  24. What you're seeing is the default landing page for Laravel. If you're surfing to http://localhost:8000/ it's matching the '/' route in the web.php file, so it'll render the welcome.blade.php file. If you want to see your questions/* routes you need to request them - go to http://localhost:8000/questions.
  25. Check the content of your arrays. It looks like $allowed_forums contains a blank entry.
  26. The error is coming from line 347. The line containing $f = $forums['f'][$forum_id];. The message showed up when I upgraded to PHP 8.3.7 from 8.3.6. before then, there were no errors. so I'm guessing it's a deprecation error. I will try downgrading to 8.3.6. the error message reads vaguely; Undefined array key "" I changed the single quotations to double quotations and still it remains.
  1. Load more activity
×
×
  • 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.