"My ASP script works on my server but it does not work on
your server."
Checking the environment
Sometimes, it could simply be due to a difference in the
environment. Take for example, if your script contains a line like ....
MyConn.Open
"Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=C:\Inetput\wwwroot\mydatabases\sample.mdb;"
... that means you are using an absolute path in your
script.
When an absolute path is being used, it will make your
script system-dependent. In other words, the script only works on your
server. The reason being, the path "C:\Inetput\wwwroot\mydatabases\sample.mdb"
only exists in your server. When the database file is in the live
server, i.e. our server, it is at a different location, for example, "E:\home\myusername\databases\sample.mdb".
How can you find out the absolute path in the live
server? Simply by running the ASP script below. Copy the contents below
into an ASP script, upload it to the server, and visit it. Take for
example, you can put the contents below into a "print-env.asp" file,
upload that file into the "htdocs" folder, then visit it by going to
http://my-domain-name/print-env.asp.
<html>
<body>
<b>The server's domain name:</b>
<%Response.Write(Request.ServerVariables("SERVER_NAME"))%>
<br>
<b>Absolute path:</b>
<%Response.Write(Request.ServerVariables("PATH_TRANSLATED"))%>
</body>
</html>
If you run the script above, you'll notice that your
absolute path might look something like "E:\home\myusername\htdocs\print-env.asp".
This means that your script is actually residing as "E:\home\myusername\htdocs\print-env.asp"
in the server. "E:\home\myusername"
is your home directory. You are brought to this folder when you connect
to the server via FTP. You cannot see the "E:\home\myusername"
part, but you are in there. You should be able to a folder named "htdocs".
Take for example, you create a folder named "databases"
at the same level as (not inside) the "htdocs" folder, and you upload
your "sample.mdb" file inside this newly created "databases" folder. The
absolute path to your "sample.mdb" file would be "E:\home\myusername\databases\sample.mdb".
Note: Generally speaking, it is not a good idea to use
absolute paths in any scripts where possible. As mentioned earlier,
using an absolute path will make a script system-dependent, and you'll
need to change it whenever the script moves to a different server.
If your script needs a SMTP host, you can use
"127.0.0.1".
|