Skip to main content
Known Participant
July 24, 2023
Question

php notice warning id

  • July 24, 2023
  • 1 reply
  • 373 views
[24-Jul-2023 07:58:29 UTC] PHP Notice:  Use of undefined constant id - assumed 'id' in

may i know what does the php notice mean

 /home/pbv3iybckwao/public_html/product.php on line 72
[24-Jul-2023 07:58:29 UTC] PHP Notice:  Undefined index: id in /home/pbv3iybckwao/public_html/product.php on line 72

 

    This topic has been closed for replies.

    1 reply

    BenPleysier
    Community Expert
    Community Expert
    July 24, 2023

    With $_GET['id'], you are trying to access a variable that comes from the URL query parameter as in product.php?id=123. When the parameter does not exist, you will get the error message.

     

    It is better to reconstruct the code to check if the parameter exists as in

     

    // Check if $_GET ['id'] is set
    if (isset ($_GET ['id'])) {
      // Use $_GET ['id']
      $id = $_GET ['id'];
    } else {
      // Handle the case when $_GET ['id'] is not set
      // For example, show an error message or redirect to another page
      echo "No id provided";
    }
    

     

     

     

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Known Participant
    July 26, 2023

    Please check if the above coding has error.

    i used your method to test and really no "no id is provided"

    Legend
    July 26, 2023

    Echo the id on the product.php page after you $_GET it, assuming you are linking to that page from the page which passes the id via the url. Do you have any result.

     

    I assume you are not trying to open the products.php page directly, which will throw the error/warning.