Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. 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?
  3. Today
  4. 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.
  5. 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 | +--------------+---------------------+---------------------+-----------+
  6. 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.
  7. 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
  8. ...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
  9. I am not storing them, Jira is storing them in this format. Export to Jira->CSV->Import to MySql.
  10. 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.
  11. 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
  12. 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
  13. 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
  14. Yesterday
  15. Last week
  16. 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!!!
  17. If you don't want to use the extension then don't install it 😕
  18. 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?
  19. 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.
  20. Check the content of your arrays. It looks like $allowed_forums contains a blank entry.
  21. 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.
  22. Oops! Sorry, I won't make that mistake again! OK, I understand your hint. I've seen similar examples and just didn't understand until now. Thanks for your help (and for correcting me about uploading code). Dave
  23. On this site, we do not normally open attachments. In order to post code, use the <> button located in the toolbar. As for your issue, the PHP script will be read by the server when loading the webpage. It is currently doing what you have directed it to do (and has proven that it functions adequately). If you want to change your instructions to not run unless the submit button is clicked, then you have created a new CONDITION that needs to be added to the code. There are several ways to handle this: //let's say this is your button <input type="submit" name="my_submit" value="runPHP"> //Assuming the button is inside a <form method="POST"> tag, you now have several alternatives or combinations to use as conditions <?php if(isset($_POST['my_submit'])){ //code to run if the CONDITION is met hours here } else { //what to do if condition is NOT met echo "Sorry, the button was not clicked"; } //end the condition //OR do this if you want to meet a greater condition if(isset($_POST['my_submit']) && $_POST['my_submit'] == "runPHP"){ //code to run if ALL the CONDITIONs are met } else { //what to do if conditionS are NOT met echo "Sorry, the button was not clicked"; } //end the conditions statement ?> Hope this helps. You can research ISSET and see other examples online.
  24. BTW, I changed the name from test.php just so I could upload it.
  25. Hi, I'm struggling to get a simple example to work (with really no experience in php and just enough to make things work in html). My problem is this simple web page runs the php script when the page is loaded, writing to a file. I don't want the script to run until the submit button is pressed. What am I doing wrong? Thanks, Dave test.php.txt
  26. Hi, I am a newbie to Laravel and trying to familiarize myself with it, so I am starting with a CBT project and when I navigate to http://127.0.0.1:8000/, it keeps taking me to laravel news page which differ from my project page. Here is my web.php <?php use Illuminate\Foundation\Application; use Illuminate\Support\Facades\Route; use Inertia\Inertia; use App\Http\Controllers\QuestionController; Route::get('questions', [QuestionController::class, 'index'])->name('questions.index'); Route::get('questions/create', [QuestionController::class, 'create'])->name('questions.create'); Route::post('questions', [QuestionController::class, 'store'])->name('questions.store'); Route::get('/', function () { return Inertia::render('Welcome', [ 'canLogin' => Route::has('login'), 'canRegister' => Route::has('register'), 'laravelVersion' => Application::VERSION, 'phpVersion' => PHP_VERSION, ]); }); Route::middleware([ 'auth:sanctum', config('jetstream.auth_session'), 'verified', ])->group(function () { Route::get('/dashboard', function () { return Inertia::render('Dashboard'); })->name('dashboard'); }); And here is the page I keeps loading to Please advise and if I could get a comprehensive tutorial that will guide me to pass the hurdles. I find it a bit difficult but with its authentication built in, it is okay.
  27. The extension still gets loaded and functions will still exist. Changing the xdebug.mode merely tells Xdebug not to do anything. https://xdebug.org/docs/all_settings#mode
  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.