Which of the following is the best choice for the DW database connection path?

Source: Internet
Author: User
Tags web hosting

Using the Dreamweaver MX dynamic website database path

1. Server. Mappath is not recommended (database files with relative document paths)

Although the platform is portable, the correctness of the database path cannot be completely guaranteed for files that reference the database at different levels and depths.

For example:

1. The database file cnbruce. mdb is located in the database folder (accessible through http)
2. The Connection database file conn. asp automatically generated by DW, In the Connections folder.
3. If the connection path is successfully tested in DW, you must enter the address Server. Mappath ("../database/cnbruce. mdb ")
However, the files that reference the database connection must be saved in a folder, which is the same as the database.

That is:

-Database
-Cnbruce. mdb
-Connections
-Conn. asp
-A folder
-X1.asp

This structure can be used normally. However, this requires that all files that reference database files in the site must be stored in the first-level directory of the site. Obviously this is unreasonable, such as the structure.

-X2.asp
-Database
-Cnbruce. mdb
-Connections
-Conn. asp
-A folder
-A subfolder
-X3.asp

X2.asp and x3.asp cannot be displayed normally.

Principle Analysis: No matter where conn. asp is put, regardless of the content of conn. asp, it depends on the file location of the file referenced by conn. asp and the location relationship of the database. Explanation:Http://www.cnbruce.com/blog/showlog.asp? Cat_id = 26 & log_id = 423

Solution: determine the current path in conn. asp and provide different link paths according to different levels of values ...... It is troublesome for beginners.
The second solution is to use the relative root directory method, but it is not recommended.

2. Server. Mappath (database file relative to the root directory) is not recommended)

To use this method, you must first adjust the default IIS Site to the folder (XP system) where the current DW site is located, or create a site pointing to the folder (2 k system ).

If you enterHttp: // localhost/The displayed content is not the default IIS homepage, but the default homepage document in the DW site folder you set.

After setting the IIS Site

1. The database file cnbruce. mdb is located in the database folder (accessible through http)
2. The Connection database file conn. asp automatically generated by DW, In the Connections folder.
3. If the connection path is successfully tested in DW, the input address is Server. Mappath ("/database/cnbruce. mdb ")

/Database/cnbruce. mdbThis method is relative to the root directory, and the database path is obtained in a high-built manner. The site documents under the directory can be normally displayed at any level.

But still not recommended! The reason is as follows:

You can modify the IIS Site locally. When it is uploaded to the server or virtual host, the problem arises.

1. If your web hosting service provider is not technically close, when parsing the root directory of your website, it does not point to your site folder, but to the wwwroot folder under the server system disk. The path is definitely incorrect.
2. If you do not need to upload the root directory of your site, it is clear that the path will certainly have a parsing error.

Therefore, it is not recommended ·! So what should we do?

3. Recommended (database files in the absolute local physical path)

It's easy. You will always know where the database is located locally. This absolute physical path address is used directly when you create an image in DW.

OK. Of course, it is not so clever: the physical path address of the database uploaded to the server is the same as the physical path address of the local database -__-!

Therefore, you only need to obtain the database files uploaded to the server space and the physical address on the server.

How to get it?

1. Create a path. asp file with simple content

<% = Server. mappath ("cnbruce. mdb") %>

2. The file and the database file cnbruce. mdb are in a folder and bundled together for upload.
3. Check path. asp in the URL address bar to obtain the physical address of cnbruce. mdb on the server and copy the path.
4. Replace the physical path in the local conn. asp file and upload it again. Everything is OK!

Features:
1. Although the platform migration is not strong, it fully supports file connections across all sites, that is, the migration between the local and server.
2. Prevent the % 5c brute-force database from indirectly obtaining the database address.
3. We recommend that you store database files in non-Web access directories in more and more spaces. Therefore, you must use physical paths.

So my point is:

How to Use the Dreamweaver MX dynamic website database path:

The physical address is used locally, and the upload server still uses the physical address.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.