PHP Error - BASE_URL - username - CodeIgniter









up vote
0
down vote

favorite












A while ago I attempted to re-open previous work but could not get the XAMPP Control Panel to open, I guess because I re-installed Windows 10. I then decided to download the latest versions of XAMPP & CodeIgniter and then transfer my previous files to the new system.



Previous CI_VERSION = '3.1.1' - Latest CI_VERSION = '3.1.9' - Previous PHP version: 7.0.8 - Latest PHP version 7.2.3



When my current system directs to the "username" page which is where the username & password are created, I get the following error. This function was working OK in my previous system. It appears to be caused by a difference between the versions of PHP.




A PHP Error was encountered
Severity: Warning



Message: Use of undefined constant BASE_URL - assumed 'BASE_URL' (this will throw an Error in a future version of PHP)



Filename: username.php
Line Number: 47




This is Line 47



<form class="form" method="post" action="<?php echo BASE_URL . 'username'; ?>">



Backtrace:



File: C:xampphtdocsapplicationviewsusername.php
Line: 47
Function: _error_handler
This is Line 47 - ">



File: C:xampphtdocsapplicationcontrollersUsername.php
Line: 70
Function: view
This is Line 70 - $this->load->view('username', $data);



File: C:xampphtdocsindex.php
Line: 315
Function: require_once
BASE_URLusername">
This is Line 315 - require_once BASEPATH.'core/CodeIgniter.php';




Can somebody advise me of what I need to change?



Update 1



The only place I can find a definition of base_url is in /config/config.php which is following;



$config['base_url'] = 'http://localhost/';


And that has not been changed between my previous work and this current system.



Update 2



In the Controller Username.php there is a load function



$this->load->helper(array('form', 'url'));


But I can't find anything in the helper folder other than index file.



And again that has not been changed between my previous work and this current system.










share|improve this question























  • Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
    – Qirel
    Nov 10 at 14:05














up vote
0
down vote

favorite












A while ago I attempted to re-open previous work but could not get the XAMPP Control Panel to open, I guess because I re-installed Windows 10. I then decided to download the latest versions of XAMPP & CodeIgniter and then transfer my previous files to the new system.



Previous CI_VERSION = '3.1.1' - Latest CI_VERSION = '3.1.9' - Previous PHP version: 7.0.8 - Latest PHP version 7.2.3



When my current system directs to the "username" page which is where the username & password are created, I get the following error. This function was working OK in my previous system. It appears to be caused by a difference between the versions of PHP.




A PHP Error was encountered
Severity: Warning



Message: Use of undefined constant BASE_URL - assumed 'BASE_URL' (this will throw an Error in a future version of PHP)



Filename: username.php
Line Number: 47




This is Line 47



<form class="form" method="post" action="<?php echo BASE_URL . 'username'; ?>">



Backtrace:



File: C:xampphtdocsapplicationviewsusername.php
Line: 47
Function: _error_handler
This is Line 47 - ">



File: C:xampphtdocsapplicationcontrollersUsername.php
Line: 70
Function: view
This is Line 70 - $this->load->view('username', $data);



File: C:xampphtdocsindex.php
Line: 315
Function: require_once
BASE_URLusername">
This is Line 315 - require_once BASEPATH.'core/CodeIgniter.php';




Can somebody advise me of what I need to change?



Update 1



The only place I can find a definition of base_url is in /config/config.php which is following;



$config['base_url'] = 'http://localhost/';


And that has not been changed between my previous work and this current system.



Update 2



In the Controller Username.php there is a load function



$this->load->helper(array('form', 'url'));


But I can't find anything in the helper folder other than index file.



And again that has not been changed between my previous work and this current system.










share|improve this question























  • Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
    – Qirel
    Nov 10 at 14:05












up vote
0
down vote

favorite









up vote
0
down vote

favorite











A while ago I attempted to re-open previous work but could not get the XAMPP Control Panel to open, I guess because I re-installed Windows 10. I then decided to download the latest versions of XAMPP & CodeIgniter and then transfer my previous files to the new system.



Previous CI_VERSION = '3.1.1' - Latest CI_VERSION = '3.1.9' - Previous PHP version: 7.0.8 - Latest PHP version 7.2.3



When my current system directs to the "username" page which is where the username & password are created, I get the following error. This function was working OK in my previous system. It appears to be caused by a difference between the versions of PHP.




A PHP Error was encountered
Severity: Warning



Message: Use of undefined constant BASE_URL - assumed 'BASE_URL' (this will throw an Error in a future version of PHP)



Filename: username.php
Line Number: 47




This is Line 47



<form class="form" method="post" action="<?php echo BASE_URL . 'username'; ?>">



Backtrace:



File: C:xampphtdocsapplicationviewsusername.php
Line: 47
Function: _error_handler
This is Line 47 - ">



File: C:xampphtdocsapplicationcontrollersUsername.php
Line: 70
Function: view
This is Line 70 - $this->load->view('username', $data);



File: C:xampphtdocsindex.php
Line: 315
Function: require_once
BASE_URLusername">
This is Line 315 - require_once BASEPATH.'core/CodeIgniter.php';




Can somebody advise me of what I need to change?



Update 1



The only place I can find a definition of base_url is in /config/config.php which is following;



$config['base_url'] = 'http://localhost/';


And that has not been changed between my previous work and this current system.



Update 2



In the Controller Username.php there is a load function



$this->load->helper(array('form', 'url'));


But I can't find anything in the helper folder other than index file.



And again that has not been changed between my previous work and this current system.










share|improve this question















A while ago I attempted to re-open previous work but could not get the XAMPP Control Panel to open, I guess because I re-installed Windows 10. I then decided to download the latest versions of XAMPP & CodeIgniter and then transfer my previous files to the new system.



Previous CI_VERSION = '3.1.1' - Latest CI_VERSION = '3.1.9' - Previous PHP version: 7.0.8 - Latest PHP version 7.2.3



When my current system directs to the "username" page which is where the username & password are created, I get the following error. This function was working OK in my previous system. It appears to be caused by a difference between the versions of PHP.




A PHP Error was encountered
Severity: Warning



Message: Use of undefined constant BASE_URL - assumed 'BASE_URL' (this will throw an Error in a future version of PHP)



Filename: username.php
Line Number: 47




This is Line 47



<form class="form" method="post" action="<?php echo BASE_URL . 'username'; ?>">



Backtrace:



File: C:xampphtdocsapplicationviewsusername.php
Line: 47
Function: _error_handler
This is Line 47 - ">



File: C:xampphtdocsapplicationcontrollersUsername.php
Line: 70
Function: view
This is Line 70 - $this->load->view('username', $data);



File: C:xampphtdocsindex.php
Line: 315
Function: require_once
BASE_URLusername">
This is Line 315 - require_once BASEPATH.'core/CodeIgniter.php';




Can somebody advise me of what I need to change?



Update 1



The only place I can find a definition of base_url is in /config/config.php which is following;



$config['base_url'] = 'http://localhost/';


And that has not been changed between my previous work and this current system.



Update 2



In the Controller Username.php there is a load function



$this->load->helper(array('form', 'url'));


But I can't find anything in the helper folder other than index file.



And again that has not been changed between my previous work and this current system.







php codeigniter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 19:14

























asked Nov 10 at 14:03









user225359

1417




1417











  • Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
    – Qirel
    Nov 10 at 14:05
















  • Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
    – Qirel
    Nov 10 at 14:05















Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
– Qirel
Nov 10 at 14:05




Possible duplicate of What does the PHP error message "Notice: Use of undefined constant" mean?
– Qirel
Nov 10 at 14:05












4 Answers
4






active

oldest

votes

















up vote
0
down vote













The constant BASE_URL was defined somewhere in the old code but is not in the new. CodeIgniter does not define a constant called BASE_URL so it was done in some custom code. It probably looked something like this



define('BASE_URL', base_url());


There are other ways to obtain the value so the main thing to look for is define('BASE_URL',.



Likely places to look are customized versions of /config/config.php or /config/constants.php, but there are lots of other places including a base controller, custom library or some other user-created configuration file.






share|improve this answer



























    up vote
    0
    down vote













    I couldn't find any constant called BASE_URL in the latest CodeIgniter source code.
    Their documentation recommends using the base_url() function for returning the site's base URL.
    https://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=base_url#base_url



    There was, however, and older repo on GitHub where I could find a version of CodeIgniter where the constant BASE_URL was defined in the constants.php file.
    https://github.com/assoft/codeigniter/blob/master/application/config/constants.php
    Probably this was common practice for older versions.



    So, in your example you can use the base_url() function. This should output http://www.example.com/username



    <form class="form" method="post" action="<?php echo base_url('username'); ?>">


    You have to import the url helper in the method of the controller corresponding to the view you're using.



    $this->load->helper('url');


    You should also fill in the value for the base url in the application/config/config.php file.



    $config['base_url'] = 'http://www.example.com';





    share|improve this answer








    New contributor




    Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      up vote
      0
      down vote













      you have to define base_url. i am using this in header file.



       <script>
      var base_url = '<?php echo base_url(); ?>';
      </script>





      share|improve this answer



























        up vote
        0
        down vote













        I found my problem. In constants.php of my old system there is the following,



        define('BASE_URL', 'http://localhost/');


        I copied that into the my current contants.php file and it works, that is to say I don't get the error.






        share|improve this answer




















          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239738%2fphp-error-base-url-username-codeigniter%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          The constant BASE_URL was defined somewhere in the old code but is not in the new. CodeIgniter does not define a constant called BASE_URL so it was done in some custom code. It probably looked something like this



          define('BASE_URL', base_url());


          There are other ways to obtain the value so the main thing to look for is define('BASE_URL',.



          Likely places to look are customized versions of /config/config.php or /config/constants.php, but there are lots of other places including a base controller, custom library or some other user-created configuration file.






          share|improve this answer
























            up vote
            0
            down vote













            The constant BASE_URL was defined somewhere in the old code but is not in the new. CodeIgniter does not define a constant called BASE_URL so it was done in some custom code. It probably looked something like this



            define('BASE_URL', base_url());


            There are other ways to obtain the value so the main thing to look for is define('BASE_URL',.



            Likely places to look are customized versions of /config/config.php or /config/constants.php, but there are lots of other places including a base controller, custom library or some other user-created configuration file.






            share|improve this answer






















              up vote
              0
              down vote










              up vote
              0
              down vote









              The constant BASE_URL was defined somewhere in the old code but is not in the new. CodeIgniter does not define a constant called BASE_URL so it was done in some custom code. It probably looked something like this



              define('BASE_URL', base_url());


              There are other ways to obtain the value so the main thing to look for is define('BASE_URL',.



              Likely places to look are customized versions of /config/config.php or /config/constants.php, but there are lots of other places including a base controller, custom library or some other user-created configuration file.






              share|improve this answer












              The constant BASE_URL was defined somewhere in the old code but is not in the new. CodeIgniter does not define a constant called BASE_URL so it was done in some custom code. It probably looked something like this



              define('BASE_URL', base_url());


              There are other ways to obtain the value so the main thing to look for is define('BASE_URL',.



              Likely places to look are customized versions of /config/config.php or /config/constants.php, but there are lots of other places including a base controller, custom library or some other user-created configuration file.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 10 at 15:56









              DFriend

              6,1701520




              6,1701520






















                  up vote
                  0
                  down vote













                  I couldn't find any constant called BASE_URL in the latest CodeIgniter source code.
                  Their documentation recommends using the base_url() function for returning the site's base URL.
                  https://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=base_url#base_url



                  There was, however, and older repo on GitHub where I could find a version of CodeIgniter where the constant BASE_URL was defined in the constants.php file.
                  https://github.com/assoft/codeigniter/blob/master/application/config/constants.php
                  Probably this was common practice for older versions.



                  So, in your example you can use the base_url() function. This should output http://www.example.com/username



                  <form class="form" method="post" action="<?php echo base_url('username'); ?>">


                  You have to import the url helper in the method of the controller corresponding to the view you're using.



                  $this->load->helper('url');


                  You should also fill in the value for the base url in the application/config/config.php file.



                  $config['base_url'] = 'http://www.example.com';





                  share|improve this answer








                  New contributor




                  Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





















                    up vote
                    0
                    down vote













                    I couldn't find any constant called BASE_URL in the latest CodeIgniter source code.
                    Their documentation recommends using the base_url() function for returning the site's base URL.
                    https://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=base_url#base_url



                    There was, however, and older repo on GitHub where I could find a version of CodeIgniter where the constant BASE_URL was defined in the constants.php file.
                    https://github.com/assoft/codeigniter/blob/master/application/config/constants.php
                    Probably this was common practice for older versions.



                    So, in your example you can use the base_url() function. This should output http://www.example.com/username



                    <form class="form" method="post" action="<?php echo base_url('username'); ?>">


                    You have to import the url helper in the method of the controller corresponding to the view you're using.



                    $this->load->helper('url');


                    You should also fill in the value for the base url in the application/config/config.php file.



                    $config['base_url'] = 'http://www.example.com';





                    share|improve this answer








                    New contributor




                    Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.



















                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      I couldn't find any constant called BASE_URL in the latest CodeIgniter source code.
                      Their documentation recommends using the base_url() function for returning the site's base URL.
                      https://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=base_url#base_url



                      There was, however, and older repo on GitHub where I could find a version of CodeIgniter where the constant BASE_URL was defined in the constants.php file.
                      https://github.com/assoft/codeigniter/blob/master/application/config/constants.php
                      Probably this was common practice for older versions.



                      So, in your example you can use the base_url() function. This should output http://www.example.com/username



                      <form class="form" method="post" action="<?php echo base_url('username'); ?>">


                      You have to import the url helper in the method of the controller corresponding to the view you're using.



                      $this->load->helper('url');


                      You should also fill in the value for the base url in the application/config/config.php file.



                      $config['base_url'] = 'http://www.example.com';





                      share|improve this answer








                      New contributor




                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.









                      I couldn't find any constant called BASE_URL in the latest CodeIgniter source code.
                      Their documentation recommends using the base_url() function for returning the site's base URL.
                      https://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=base_url#base_url



                      There was, however, and older repo on GitHub where I could find a version of CodeIgniter where the constant BASE_URL was defined in the constants.php file.
                      https://github.com/assoft/codeigniter/blob/master/application/config/constants.php
                      Probably this was common practice for older versions.



                      So, in your example you can use the base_url() function. This should output http://www.example.com/username



                      <form class="form" method="post" action="<?php echo base_url('username'); ?>">


                      You have to import the url helper in the method of the controller corresponding to the view you're using.



                      $this->load->helper('url');


                      You should also fill in the value for the base url in the application/config/config.php file.



                      $config['base_url'] = 'http://www.example.com';






                      share|improve this answer








                      New contributor




                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.









                      share|improve this answer



                      share|improve this answer






                      New contributor




                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.









                      answered Nov 10 at 18:37









                      Dan D.

                      1546




                      1546




                      New contributor




                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.





                      New contributor





                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.






                      Dan D. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.




















                          up vote
                          0
                          down vote













                          you have to define base_url. i am using this in header file.



                           <script>
                          var base_url = '<?php echo base_url(); ?>';
                          </script>





                          share|improve this answer
























                            up vote
                            0
                            down vote













                            you have to define base_url. i am using this in header file.



                             <script>
                            var base_url = '<?php echo base_url(); ?>';
                            </script>





                            share|improve this answer






















                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              you have to define base_url. i am using this in header file.



                               <script>
                              var base_url = '<?php echo base_url(); ?>';
                              </script>





                              share|improve this answer












                              you have to define base_url. i am using this in header file.



                               <script>
                              var base_url = '<?php echo base_url(); ?>';
                              </script>






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 12 at 7:05









                              PHP Geek

                              1,1191817




                              1,1191817




















                                  up vote
                                  0
                                  down vote













                                  I found my problem. In constants.php of my old system there is the following,



                                  define('BASE_URL', 'http://localhost/');


                                  I copied that into the my current contants.php file and it works, that is to say I don't get the error.






                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote













                                    I found my problem. In constants.php of my old system there is the following,



                                    define('BASE_URL', 'http://localhost/');


                                    I copied that into the my current contants.php file and it works, that is to say I don't get the error.






                                    share|improve this answer






















                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      I found my problem. In constants.php of my old system there is the following,



                                      define('BASE_URL', 'http://localhost/');


                                      I copied that into the my current contants.php file and it works, that is to say I don't get the error.






                                      share|improve this answer












                                      I found my problem. In constants.php of my old system there is the following,



                                      define('BASE_URL', 'http://localhost/');


                                      I copied that into the my current contants.php file and it works, that is to say I don't get the error.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 12 at 15:19









                                      user225359

                                      1417




                                      1417



























                                           

                                          draft saved


                                          draft discarded















































                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239738%2fphp-error-base-url-username-codeigniter%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          這個網誌中的熱門文章

                                          Barbados

                                          How to read a connectionString WITH PROVIDER in .NET Core?

                                          Node.js Script on GitHub Pages or Amazon S3