ProblemHelpPlease2 Posted December 13, 2018 Share Posted December 13, 2018 I have a simple problem but seem to be hitting a roadblock with fixing it. I am in the process of upgrading a site from PHP 5.6 to 7.0 (eventually to 7.2) I am seeing error notices like PHP Notice: Undefined index: productpage in ….. I know this it because the $_REQUEST can sometimes be empty depending on what data is passed back and when certain pages are loaded $productpage = mysqli_real_escape_string($con, $_REQUEST['productpage']); I also know that I could turn the error notice off or use isset to check $_REQUEST but I would prefer to use the ?? '' option to fix this issue. The problem is that when I add the ?? '' option to the above code the problem resolved itself but then moments later the same error on the same line reappeared in the error logs and I cant understand why. Can someone give me the correct example of where to place ?? '' in the above code so that I can rule out my potentially dodgy code as being the reason the error keeps reappearing. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 13, 2018 Share Posted December 13, 2018 When you added the ?? in, what did you end up with? If the error went away at all then you probably did the correct thing $productpage = mysqli_real_escape_string($con, $_REQUEST['productpage'] ?? 'some reasonable default'); which means the return of the error message means either (a) the change got somehow reverted, or more likely (b) the server is running old code because of a cache. Assuming you're running php-fpm, try restarting it. Quote Link to comment Share on other sites More sharing options...
ProblemHelpPlease2 Posted December 13, 2018 Author Share Posted December 13, 2018 Well at least I know I had the code correct as its exactly what you have provided. To answer your question the problem went away on the next run through, I had 5 errors all the same, changed 1 of them to see if it made a difference and then had 4 errors as you would expect. It was 5 minutes later that the issue reappeared. I checked the code and it still had my change in it. I wondered if it might be a cache issue but that's harder to check as the site is currently on a server that I don't have full access to. I guess the next step is to make the code change again (I reverted it) and then leave it for 24 hours and see if its still giving me the error in the logs. Thank you for your help. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 14, 2018 Share Posted December 14, 2018 Are you sure those four/five error messages are all referring to the same file and line? If that's the case then there's not much of a reason why fixing the code would only remove one message. Quote Link to comment 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.