• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1084
  • Last Modified:

WML/WAP and Database Access how do i make my WAP pages dynamic using ASP (many points!!)

Hey there guys,

i've also asked this question in the WAP section of this site so i'm also offering points here.

i've created a WAP website with a selection of ringtones for myselve that i can download on the fly - i've had to create a WAP site because my phone doesnt come with any serial cable also cables are not available in order to connect a phone to a PC.

i can use the WAP site on the move so that i can download my ringtones.

But what i want to do now is make the WAP site more dynamic as i have alot of ringtones that i want to add to the site but i know that if i had them it will take a very long time as i want them in categories and in alphatical order i'll also like a page which shows only the ringtones i've added in the last 3 days.

i know that this can be done with ASP and creating a database to store the information but how would i do this.

my idea is that i create a website which i use to input new records into the database (including the name of the ringtone, category of the ringtones, date ringtone entered, size of ringtone, full link to ringtone)

i then want to create some dynamic wml pages that let allow me to search the database, and click on a link that will open up the ringtone. and also show me the ringtones in the categories, and alphabetically.


can someone please help me with this, i'm a complete beginner - i've only just started making A WAP SITE. i'm also not really any good at ASP the ASP site i did make was using dreamweaver mx and very simple using wizards etc.

i could do with all the help in the world so i'm offering all the points i have as i would like tog et this done very very soon.


thanks again


also would it be easier to do this in asp or PHP or which dynamic lanuguage would be better?

0
MiamiDolphins
Asked:
MiamiDolphins
  • 9
  • 5
  • 5
1 Solution
 
purpleblobCommented:
Wow, that's quite a question as it covers many things - let's answer your last question first.

PHP and ASP are (for the most part) much the same, i.e. they're both server side scripting, they also both allow you to work with databases and create dynamic web sites. Would it be easier to use ASP or PHP is not one that can be answered without know more about what you already know. For example ASP can be written using VBScript (the default language) or JavaScript (well JScript - the MS JavaScript). VBScript is a pretty simple language to use so it's quite easy. PHP uses it's own language which I find resembles C in someways (although without pointers etc.) aspects of it are Perl like also.

Both PHP or ASP will do what you want, I think what you really need to do is focus on what OS you're going to use and other technologies. For example, PHP is generally the choice on a Unix/Linux based server whilst ASP (or the more recent and more powerful ASP.NET) would be Microsoft based - so which does your ISP or server use - Windows or Linux ?

As you say, what you want to do (to be truly dynamic) is store your ringtones either in a database in a blob field or store them on the server's hard drive and store the URL's to them in the database. The database for this will be fairly simple, I mean all you really need is a single table with two fields (at the minimum) the two fields would hold the name of the ringtone for easy accessibility to it and the other field either the ringtone or URL (discussed previously).

Without going massively in depth on how to do what you want, I would suggest checking out http://www.w3schools.com/asp/default.asp - you specifically need to look into connecting to databases and using RecordSets (if using old ASP). Also the same site http://www.w3schools.com/php/ but different folder will give good info. on PHP

But I think firstly you might wish to decide which technology to use (as said) this will depend partly on what server you or your ISP are running and what's available. I would probably say ASP is the easiest to learn for a beginner.

Good luck
0
 
MiamiDolphinsAuthor Commented:
thanks for your answer

firstly i know how to create the database

and i've used ASP before for HTML website i made for an university project.

but i would like to know how to do the same with WML (i used dreamweaver before for the project)


whats the first step

considering i've already made the database


how do i now connect that to an WML file?
0
 
purpleblobCommented:
Ah right, sorry I didn't grasp what level of knowledge you had on this.

Okay well to output WML through ASP you simply need to set the Response.ContentType = "text/vnd.wap.wml" and then output you WML - so for a very simple example let's say you have a file file called mypage.wml then to simply output this within asp the change the file name to have .asp extension, i.e. mypage.asp then all you really need to do is insert the following line as your first line of code

<% Response.ContentType = "text/vnd.wap.wml" %>

Obviously the usefullness of something like ASP is that you can embed ASP within your WML - the example I've given is simply to show how you can convert a .wml straight into a .asp. Obviously where it gets fun is using ASP scripting within the WML code :-)

Hope this helps
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MiamiDolphinsAuthor Commented:
interesting...

so for example i'm using dreamweaver

and i want to create an asp website.

do i just create the asp website using the dreamweaver wizards and all the nice tools etc

then at the top of the page just add the output to wml thingy?

is that all i need to do?

what about HTML tagging that may be used in dreamweaver whilst i'm creating the ASP page (e.g. font colour and all that)


will an mobile phone viewing the site ignore all that?


would the WML still connect to the database in teh same way and still be able to do all the searching of records etc
0
 
purpleblobCommented:
Basically if you create a page that can be displayed on a mobile phone, then you want to start embedding ASP into it - then all you need to do is insert the line I've supplied.

As to whether HTML is ignored by the mobile this will probably depend upon the mobile's micro browser. I'm reliably informed that some mobiles handle HTML.

The WML wouldn't connect to the database, the ASP would and you would use ASP to output the RecordSet results in WML format.
0
 
Neil ThompsonSenior Systems DeveloperCommented:
Here is a basic search form and results page to give you an idea.

I apologise but I do not have any time to spare cleaning the code specifically for you but you should find it useful.

Neil

------------------------------------------------------------------
<%
' INDEX.ASP (search form)


response.ContentType = "text/vnd.wap.wml"
Response.Buffer = True
%>

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
      <head>
            <meta forua="true" http-equiv="pragma"
                                       content="no-cache"/>
            <meta forua="true" http-equiv="Cache-Control"
                                       content="no-cache, must-revalidate"/>
      </head>
      <card id="start" title="Welcome">
      <p align="center">Appliance Search</p>
      <p align="center"><small>Enter Model No below:</small><br/></p>
            <p align="center"><input name="Query" /></p>
            <do type="accept" label="Go">
                  <go href="search.asp?Query=$(Query)" />
            </do>
      </card>
</wml>


------------------------------------------------------------------
<%

' SEARCH.ASP (results page)


xDb_Conn_Str_Appliances = "#### YOUR DATABASE ####"

response.ContentType = "text/vnd.wap.wml"
Response.Buffer = True

' grab the query sent from form
Query = Request.QueryString("Query")
%>
 
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
 
<wml>
 <head>
            <meta forua="true" http-equiv="pragma"
                                       content="no-cache"/>
            <meta forua="true" http-equiv="Cache-Control"
                                       content="no-cache, must-revalidate"/>
      </head>

<card id="start">

<p align="center"><b>R E S U L T S</b><br/></p>
<%
 
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str_Appliances
 
strsql = "select * from YOUR [#### DATABASE TABLE ####]"
strsql = strsql & " WHERE [#### FIELD TO SEARCH ####] LIKE '%" & Query & "%'"
 
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
totalRecs = rs.RecordCount
%>
<p>
<small>
<%
if rs.EOF then
response.write "No match for " & Query
else
Do While (NOT rs.EOF)
%>
<% response.write rs("#######") %> - <a href="<% response.write rs("#####") %>"><% response.write rs("#####") %></a>
<br/>
<%
rs.MoveNext
Loop
end if
%>
</small>
</p>
<%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing %>
</card>
</wml>
0
 
MiamiDolphinsAuthor Commented:
what does this mean

meta forua="true" http-equiv="pragma"
                                 content="no-cache"/>
          <meta forua="true" http-equiv="Cache-Control"
                                 content="no-cache, must-revalidate"/>


and this

response.ContentType = "text/vnd.wap.wml"
Response.Buffer = True

i'm reinstalling dreamweaver now

then i'll give it a go later

is it possible to make the site so that it will work as a HTML and a WML

e.g it will display WML(asp) if its being viewed by an mobile phone etc

and HTML (asp) if its being viewed by PC

i have 400 spare points so will increase if needed
0
 
purpleblobCommented:
Response.ContentType tell the browser what the content of the stream coming back is - so for example if you have a word doc in a database you can set the ContentType to that which word uses and the browser will then interact with the stream as if it was a .doc file stored on your hard drive.

Response.Buffer means buffer the output, i.e. do not send anything to the client until we've finished building the data.

The meta tags are not a requirement for what you wish to do, I'm sure NeilT will confirm - but if I recall they tell the browser not to cache the page.

You could make a page both HTML or WML capable but more likely would be to have a home page (i.e. default.asp) which check the browser type. If it's a mobile then redirect the user to a WML version of your main page, whilst if it's IE or other desktop browser redirect to the HTML version of your page. You could attempt to create a single file to handle both HTML & WML but to be honest it'll be a pain to maintain and debug.
0
 
Neil ThompsonSenior Systems DeveloperCommented:
Yes as purpleblob says, the meta tags simply force the card to be reloaded from the server and are not needed in your instance.

I did try to make a combined page a while ago, and from memory just calling the wap page as standard still worked fine on my browser, although you may have some compatability errors with older browsers.

Neil
0
 
MiamiDolphinsAuthor Commented:
I cant get it to work
below is my code for the main menu any ideas?

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/Mototone.asp" -->
<%
Dim Menu
Dim Menu_numRows

Set Menu = Server.CreateObject("ADODB.Recordset")
Menu.ActiveConnection = MM_Mototone_STRING
Menu.Source = "SELECT Category FROM Category ORDER BY Category ASC"
Menu.CursorType = 0
Menu.CursorLocation = 2
Menu.LockType = 1
Menu.Open()

Menu_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Menu_numRows = Menu_numRows + Repeat1__numRows
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/Mototone.asp" -->
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">


<wml>
<head>
<title>Main Menu</title>
<meta http-equiv="Content-Type" content="text/vnd.wap.wml"/>
 <meta forua="true" http-equiv="pragma"
                                 content="no-cache"/>
          <meta forua="true" http-equiv="Cache-Control"
                                 content="no-cache, must-revalidate"/>
</head>
<card id="start">
<p align="center"><strong>Menu</strong></p>
<p>&nbsp;</p>
<table width="200" border="0" align="center">
  <tr>
    <td>&nbsp;</td>
    <td><div align="center">
      <%
While ((Repeat1__numRows <> 0) AND (NOT Menu.EOF))
%>
      <%=(Menu.Fields.Item("Category").Value)%>
      <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Menu.MoveNext()
Wend
%>
</div></td>
    <td><div align="center"></div></td>
  </tr>
</table>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<%
Menu.Close()
Set Menu = Nothing
%>
</card>
</wml>



Any ideas guys

i think once i'm able to get one page workin on the device i'll be able to do the rest

0
 
purpleblobCommented:
What exactly is not working or is happening ?

I notice you've not got Response.ContentType = "text/vnd.wap.wml" anywhere. So you'e not sending info. to the browser to tell it what's about to arrive. Or have I missed it ?
0
 
MiamiDolphinsAuthor Commented:
is the code right?

i'm trying to read from the database on my mobile phone (wap)

but i get an internel server error message

i also get the same message from internet explorer.


so have i done the code wrong?


0
 
Neil ThompsonSenior Systems DeveloperCommented:
from memory I had errors when using includes not in the same folder try moving them to the same folder and trying again.

also remove the <%@LANGUAGE="VBSCRIPT"%>

Neil
0
 
MiamiDolphinsAuthor Commented:
Still not working at all

was my code right in the first place?

0
 
MiamiDolphinsAuthor Commented:
I'm really struggling so lets ask this question differently.

I basically want to create a dynamic WAP site.

I want to do this using ASP as thats supported on my server.

the site will not need to do much its a pretty simple site really.


heres what i want it to do.


1. connect to a access database (the database contains three tables)

TYPE
typeid
type

CATEGORY
categoryID
category

ITEM
itemid
item
category
type
URL (this is the full url to the item, which would like to be available so that you just need to click on it and it will download to your phone)

2. I want the main menu of the site will be based on the TYPE table. e.g. the type table contains. 1.Games, 2.Ringtones, Links etc - so the main menu would read the information in the table and then display it on the phone.
the user would then click on any of the main menu items and it would take them to a list of items which match that link (e.g. if they click on the games link it would pass the typeid variable and then go to the results page and only show the items where the typeid match)

3. Once the user gets into the menu item (e.g.Games) it will display a list of all the games available (all java games - .jar files) the user can then just click on the link (the link comes from the database) and then download the item.

4. i would also like facility which would allow the user to search database (e.g. if they type the word bruce, it would bring back the reasons Bruce Lee fighting - Game, Bruce Springfield - Ringtone etc)

thats all i need to do.

i know how to do this using dreamweaver MX and the tools that come with it but this makes a ASP file with HTML formatting. to convert the HTML to WML seems very difficult after looking through a few help sites so i wanted to do it just using WML and ASP.  

What do you guys think? would it be easier to create the site in dreamweaver using the HTML stuff and then try and turn the HTML into WML.

or to just do it using for example santanabuilder or nokia tools to create the ASP with WML.

i'm trying to do this because i have alot of files that i would like to make available for my phone (my phone does not have an data cable available so its near impossible to get any ringtones or games etc for the phone)

the url for my wap site at the minute is

http://mototone.com/index.wml

(i want this to be a database driven wap site)

can anyone give any example codes which could help me?

or give me some links to places that could teach me how to do this?
0
 
Neil ThompsonSenior Systems DeveloperCommented:
Hi

I'm at work now so cannot help but if you want to sent the database to nt006a6440@blueyonder.co.uk (with some dummy data in) I'll code it for you and ensure it works before i email it back

Neil
0
 
MiamiDolphinsAuthor Commented:
i've sent you an email

0
 
Neil ThompsonSenior Systems DeveloperCommented:
Hi, here are the files you need to get it working

index.asp
catagory.asp
search.asp
searchResults.asp

Best wishes
Neil

---------------------------------------------------------------
index.asp


      <%
      thisDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mototone.mdb") & ";"
      response.ContentType = "text/vnd.wap.wml"
      Response.Buffer = True
 
      set thisConn = Server.CreateObject("ADODB.Connection")
      thisConn.Open thisDatabase
      %>
      
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="start" title="Welcome">
<p align="center">MOTOTONE</p>

      <%
      strsql = "select * from [Type] ORDER BY [Type]"
      set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open strsql, thisConn, 1, 2
      'totalRecs = rs.RecordCount
      %>
<p>
<small>
      <%
      if rs.EOF then
      response.write "No Data"
      else
      Do While (NOT rs.EOF)
      %>
            <%
            strsqlCount = "select [ItemID] from [Item] WHERE Type=" & rs("TypeID")
            set rsCount = Server.CreateObject("ADODB.Recordset")
            rsCount.Open strsqlCount, thisConn, 1, 2
            totalRecs = rsCount.RecordCount      
            rsCount.Close
            Set rsCount = Nothing
            %>      
<a href="category.asp?cat=<% response.write rs("TypeID") %>"><% response.write rs("Type") %> (<% response.write totalRecs %>)</a>
<br/>
      <%
      rs.MoveNext
      Loop
      end if
      %>
</small>
</p>
      <%
      ' Close recordset and connection
      rs.Close
      Set rs = Nothing
      %>
      
<p>
<a href="search.asp">Search</a>
</p>
</card>
</wml>


      <%
      thisConn.Close
      Set thisConn = Nothing
      %>




------------------------------------------------------------
search.asp

<% response.ContentType = "text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
      <card id="Search" title="MOTOTONE" newcontext="true">
      
      <p align="center"><small>Search For:</small></p>
            <p align="center"><input name="Query"/></p>
            <do type="accept" label="Go">
                  <go href="searchResults.asp?value=$(Query)" />
            </do>
      </card>
</wml>


-----------------------------------------------------------

searchResults.asp

      <%
      thisDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mototone.mdb") & ";"
      response.ContentType = "text/vnd.wap.wml"
      Response.Buffer = True
      searchCriteria = Request.QueryString("value")      
      set thisConn = Server.CreateObject("ADODB.Connection")
      thisConn.Open thisDatabase
      strsql = "select * from [Item] WHERE [Title] LIKE '%" & searchCriteria & "%' ORDER BY Title"
      set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open strsql, thisConn, 1, 2
      totalRecs = rs.RecordCount
      %>
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="SearchResults">
<p align="center"><small>mototone</small></p>
<p align="center"><b>R E S U L T S</b><br/></p>      
<p>
<small>
      <%
      if rs.EOF then
      response.write "No match for " & searchCriteria
      else
      Do While (NOT rs.EOF)
      %>
<a href="<% response.write rs("DownloadLink") %>"><% response.write rs("Title") %></a>
<br/>
<br/>
      <%
      rs.MoveNext
      Loop
      end if
      %>
</small>
</p>
</card>
</wml>
      <%
      rs.Close
      Set rs = Nothing
      thisConn.Close
      Set thisConn = Nothing
      %>


-------------------------------------------------------------------------------

category.asp


      <%       
      thisDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mototone.mdb") & ";"
      response.ContentType = "text/vnd.wap.wml"
      Response.Buffer = True      
      cat = request.querystring("cat")
      set thisConn = Server.CreateObject("ADODB.Connection")
      thisConn.Open thisDatabase
      %>      
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="select" title="Welcome">
<p align="center">MOTOTONE</p>
      <%
      strsql = "select * from [Item] WHERE Type=" & cat
      'response.write strsql
      set rs = Server.CreateObject("ADODB.Recordset")
      rs.Open strsql, thisConn, 1, 2
      %>
<p>
<small>
      <%
      if rs.EOF then
      response.write "No results for " & cat
      else
      Do While (NOT rs.EOF)
      %>                  
<a href="<% response.write rs("DownloadLink") %>"><% response.write rs("Title") %></a>
<br/>
      <%
      rs.MoveNext
      Loop
      end if
      %>
</small>
</p>
      <%
      ' Close recordset and connection
      rs.Close
      Set rs = Nothing
      %>
</card>
</wml>
      <%
      thisConn.Close
      Set thisConn = Nothing
      %>










0
 
MiamiDolphinsAuthor Commented:
Neil you are an genius


thanks

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 9
  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now