Jump to content

Undefined Variable Error


db1993

Recommended Posts

Hello, I am receiving an error of "Notice: Undefined variable: product_id in \edit_product_gaming.php on line 24"

 

What I tried is to simply define that via :   $product_id = $_GET['product_id'];

 

This simply led to another error that there was an undefined index of 'product_id'.

 

This is really frustrating as I had it working earlier and due to ONLY moving the file from one folder to the other(to keep everything neat), and changing the URL of the form to accommodate the new directory (even though I didn't actually need to) I started to receive this error once again, if ^that had anything to do with it please let me know, otherwise I think there must be some error in the coding.

 

Would really appreciate some help on this matter

 

Thanks! 

 

 

http://pastebin.com/656RZ7DS

Link to comment
https://forums.phpfreaks.com/topic/279890-undefined-variable-error/
Share on other sites

Does the GET variable appear in the website URL?

 

 

Note: the code should be changed to something like this:

$product_id = (isset($_GET['product_id'])) ? $_GET['product_id'] : '';

That way $product_id will always be set to something; even if the GET variable is missing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.