[RESOLVED] Use of undefined constant submit
Hello everybody,
I am getting following error.
Notice: Use of undefined constant submit - assumed 'submit' in E:\Projects\RxClub\rxclub\admin\admin_upload.php on line 18
Line 18 is
Code:
if ($_POST[submit]){
I am getting this error on almost all the pages and on different lines, however, I downloaded the site and its working fine online.
Any ideas ??
Thanks.
Re: Use of undefined constant submit
submit needs to be enclosed in quote marks, as the error message says.
PHP Code:
if ($_POST['submit'])
Re: Use of undefined constant submit
You get this notice when you try and access something that has not been set yet, although PHP doesnt mind because it is dynamicly cast its looks neater and runns better if you check to see if the value is set before hand.
PHP Code:
if(isset($_POST['submit']))
{
if($_POST['submit'] == 'somevalue')
{
//do some stuff
}
}
[EDIT]
woops :rolleyes: was thinking off "Notice: Undefined variable" penagates post will fix it though :)
Re: Use of undefined constant submit
Quote:
Originally Posted by usamaalam
Hello everybody,
I am getting following error.
Notice: Use of undefined constant submit - assumed 'submit' in E:\Projects\RxClub\rxclub\admin\admin_upload.php on line 18
Line 18 is
Code:
if ($_POST[submit]){
I am getting this error on almost all the pages and on different lines, however, I downloaded the site and its working fine online.
Any ideas ??
Thanks.
Your website probably has display of notices disabled. As mentioned above, you should enclose textual array indexes in quotes.
I recommend you fix those things so you do not get any notices. Notices serve to warn you about use of undefined variables and use of undefined constants like you have seen above and when not ignored they can be used to indicate errors in your coding such as missspelt variable and constant names.
Re: Use of undefined constant submit
Is there a way to disable notice messages throughout the website. I have a large running website downloaded on my system and these messages are scattered on almost all the pages.
Thanks.
Re: Use of undefined constant submit
You can disable them globally by modifying the error_reporting directive in the php.ini file.
Re: Use of undefined constant submit
How can I disable error_reporting directive in php.ini file. I am extremely new to PHP.
Thanks.
Re: Use of undefined constant submit
I commented out the error_reporting = E_ALL; line and its working now.
Thanks.