• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

php notice warning id

Explorer ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

[24-Jul-2023 07:58:29 UTC] PHP Notice:  Use of undefined constant id - assumed 'id' in

Screen Shot 2023-07-24 at 17.41.19.png

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

 

Views

170

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 24, 2023 Jul 24, 2023

Copy link to clipboard

Copied

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, the only real Dreamweaver alternative.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

Screen Shot 2023-07-26 at 18.39.47.png

Screen Shot 2023-07-26 at 18.40.00.png

Please check if the above coding has error.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2023 Jul 30, 2023

Copy link to clipboard

Copied

LATEST

im figuring out the problem. 

thanks for your suggestion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines