Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Best way of using includes

New Here ,
Jun 08, 2013 Jun 08, 2013

Hi there,

I have a question about the use of includes.

Every time I use them I get some sort of erros and I always spend way to much time trying to nest things up.

I usually have one include for the connection, one for the menu and a few more. As you start building the

page, Dreamweaver adds heavy coding and often the reference to the different include files adds up through

the different pages. If the same reference appears twice in a page you need to remove one of them, but then

some recordset loses it's connection and you get the red mark in the bindings/server behavior.

So my question is this: for a scenario where I need to use includes for a connection, a menu and a few recordsets,

what would be the best way to set things up in order to prevent a conflict?

I have been walking the path of learning by doing over the years and I suspect there is a better way of building a

page when using includes.

Thanks in advance for any answers or hints,

Christian

DWCS5 | Asp | Access

TOPICS
Server side applications
618
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jun 13, 2013 Jun 13, 2013

Firstly, it sounds like you are letting DW write code for you. Write your own code. NEVER have a program like DW write any of your code. None. The issues you are describing simply would not occur if you were writing your own code. Your own code will be terse and easier to read and maintain. DW often does simple things in complicated ways.

I try to put as much of my logic code (PHP for me, ASP for you) at the top of the page, even above the HTML tag, so the HTML presentation code is not very  mixed up with the logic code. At first this might feel clumsy and your results might not be efficient, but eventually you will learn tricks to make this work effectively.

The method above allows you to organize your code categorically so that you are not forced to make your code follow the presentation sequence. This can be especially useful if the script is long (over 500 lines).

Use includes only for code that is used in more than one script. Write functions and build classes for logic that is repeated.

Store your database connection include above the web root where it won't be as easy for someone else to access it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 14, 2013 Jun 14, 2013
LATEST

Hi Rob,

You are right about me letting DW write my code. Been thinking of hardcoding most of the stuff myself, but as you mentioned it takes a while to get on the right track.

But I might as well dive into it, not only do you have total control, it will also make it easier to understand and fix errors later.

Thank you for all your tips, appreciated!

Christian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines