Jump to content

UmarFarooq

New Members
  • Posts

    2
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://avogtal.com

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

UmarFarooq's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The error message you are encountering is a "Warning: A non-numeric value encountered." This warning indicates that you are trying to perform a mathematical operation involving a non-numeric value. In your case, the issue seems to be with the variable $total_price or $quantities being non-numeric. To resolve this error, you can follow these steps: Ensure that the $total_price variable is properly initialized and assigned a numeric value before the line where the error occurs. Verify that you have code that sets the initial value for $total_price correctly. Check the value of $quantities by adding a debug statement before the problematic line. For example, you can use var_dump($quantities); to print the value and its data type. Make sure it is a numeric value. If $quantities is not a numeric value, you should investigate why it's not being assigned correctly. Check the form where the quantity is submitted ($_POST['qty']) and ensure that the input field is correctly defined with the name attribute set to "qty". Additionally, make sure that only numeric values are being entered into that input field. If you find that $quantities is indeed a non-numeric value, you can add input validation to ensure that only valid numeric values are submitted. You can use PHP functions like is_numeric() or filter_var() to validate the input and handle any non-numeric cases accordingly. By following these steps, you should be able to identify and fix the issue causing the warning. For remote jobs as a PHP developer you can visit our site Avogtal
  2. I can help This is the code <?php session_start(); // Initialize session variables if (!isset($_SESSION['start_time'])) { $_SESSION['start_time'] = 0; $_SESSION['pause_time'] = 0; $_SESSION['total_pause_time'] = 0; } // Start the stopwatch if (isset($_POST['start'])) { $_SESSION['start_time'] = time(); $_SESSION['pause_time'] = 0; $_SESSION['total_pause_time'] = 0; } // Pause the stopwatch if (isset($_POST['pause'])) { $_SESSION['pause_time'] = time(); } // Resume the stopwatch if (isset($_POST['resume'])) { $_SESSION['total_pause_time'] += time() - $_SESSION['pause_time']; $_SESSION['pause_time'] = 0; } // Stop the stopwatch if (isset($_POST['stop'])) { $_SESSION['start_time'] = 0; $_SESSION['pause_time'] = 0; $_SESSION['total_pause_time'] = 0; } // Calculate the elapsed time function getElapsedTime() { if ($_SESSION['start_time'] > 0) { $elapsed_time = time() - $_SESSION['start_time'] - $_SESSION['total_pause_time']; return $elapsed_time; } return 0; } ?> <!DOCTYPE html> <html> <head> <title>Stopwatch</title> </head> <body> <h1>Stopwatch</h1> <h2><?php echo gmdate("H:i:s", getElapsedTime()); ?></h2> <form method="POST"> <?php if ($_SESSION['start_time'] == 0) { ?> <button type="submit" name="start">Start</button> <?php } else { ?> <?php if ($_SESSION['pause_time'] == 0) { ?> <button type="submit" name="pause">Pause</button> <?php } else { ?> <button type="submit" name="resume">Resume</button> <?php } ?> <button type="submit" name="stop">Stop</button> <?php } ?> </form> </body> </html>
×
×
  • 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.