Hi,

i have lots of pages where i have to write mysql_connect() fuction in top of every page. So now i want to create an inc file which will replace all my sql_connect() function. So could u please help me how to create an inc file.

    If your httpd is configured to associate .inc file extensions with PHP, you can simply make the .inc file as you would any other .php script. Then add the code that you wish to have included in the file.

    A good idea though, would be to just use the normal .php extension for the include files, in case you change web hosts, or have a situation where .inc isn't being parsed by PHP, you won't have to worry about the source being available by anyone grabbing the include file directly.

    Other things to consider regarding security measures to implement with the include files... As always, verify all incoming arguments, and if possible limit them to none or just the bare neccessities. Also, read up on the include_once() and require_once() functions for added precautionary measures.

    Good luck.

    • tre
      <a href="http://piclabs.com">PicLabs.com</a>

      Thanks for help. If u don't mind could u please give me an example regarding this. I understand what you wanted to say but if you give me an example it will be better.

      thanking you in advance

        I usually do it like this:

        require "include_file.inc";

        and that's it. no fiddling with httpd or something else..

          Write a Reply...