db1993 Posted July 5, 2013 Share Posted July 5, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/279890-undefined-variable-error/ Share on other sites More sharing options...
cyberRobot Posted July 5, 2013 Share Posted July 5, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/279890-undefined-variable-error/#findComment-1439518 Share on other sites More sharing options...
Solution db1993 Posted July 5, 2013 Author Solution Share Posted July 5, 2013 Thank you , what you said worked, but stupidly I changed the URL of the previous page which actually had the variable set, so without that page the variable wasn't known therefore holding no data. Thanks a lot for your help cyber! Quote Link to comment https://forums.phpfreaks.com/topic/279890-undefined-variable-error/#findComment-1439521 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.