WML / WAP can you use php?

Soldato
Joined
18 Oct 2002
Posts
9,044
Location
London
As part of one of our uni assignments we have to do some wml and gather information from mysql. Can I use php in there to get data? I can't figure out how I would connect to a database from it.

For example, how would I dynamically create the list below, based on records from the DB?

Code:
<?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="card1" title="Tutorial">
<do type="accept" label="Answer">
  <go href="#card2"/>
</do>
<p>
[B]<select name="name"> 
  <option value="HTML">HTML Tutorial</option>
  <option value="XML">XML Tutorial</option>
  <option value="WAP">WAP Tutorial</option>
</select>[/B]
</p>
</card>

<card id="card2" title="Answer">
<p>
You selected: $(name)
</p>
</card>

</wml>


Is it as simple as making a normal php script and just generating the basic wml tag output (card,wml,do,go, etc)? And then naming it blah.wml?

Also is there any good software for testing it on? If you load it up in apache it just gives you the option to download the file.
W3Schools recommends Nokia Mobile Internet Toolkit, but it sounds a bit biased...

Thanks for any info! I'm a bit lost with WAP stuff, my phone doesn't even support it :o
 
KingAdora said:
As part of one of our uni assignments we have to do some wml and gather information from mysql. Can I use php in there to get data? I can't figure out how I would connect to a database from it.

For example, how would I dynamically create the list below, based on records from the DB?

Code:
<?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="card1" title="Tutorial">
<do type="accept" label="Answer">
  <go href="#card2"/>
</do>
<p>
[B]<select name="name"> 
  <option value="HTML">HTML Tutorial</option>
  <option value="XML">XML Tutorial</option>
  <option value="WAP">WAP Tutorial</option>
</select>[/B]
</p>
</card>

<card id="card2" title="Answer">
<p>
You selected: $(name)
</p>
</card>

</wml>


Is it as simple as making a normal php script and just generating the basic wml tag output (card,wml,do,go, etc)? And then naming it blah.wml?

Also is there any good software for testing it on? If you load it up in apache it just gives you the option to download the file.
W3Schools recommends Nokia Mobile Internet Toolkit, but it sounds a bit biased...

Thanks for any info! I'm a bit lost with WAP stuff, my phone doesn't even support it :o
PHP doesn't care what its outputting, just treat it as you would HTML, but you're outputting WML instead.

WML is a standard, a rather strict XML based standard. The Nokia kit will be as good as any.
 
The trouble I'm having is if I put php into my wml page the phone says unsupported content type.

This is what I have (note the php testing bit)
Code:
<?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="card1" title="Parcel Finder">
  <do type="accept" label="Search">
   <go href="#card2"/>
  </do>
  <p>Enter your name to look for parcels. <?php echo 'hi'; ?></p>
  <p>Name: <input name="Name" size="15"/></p>
 </card>
</wml>

And I'm accessing it through apache:
http://localhost/mobile.wml

I don't really get what I'm supposed to do :confused:
 
Or change apache to parse wml files as php. As I believe some phones require the .wml extension. I could be mistaken though.
 
Ahh of course! :o Thanks!
I assume is it acceptable to just use .php? For some reason I assumed mobile phones would only accept .wml! [edit: thanks, I'll try and configure apache for wml, maybe that will solve my problem below?]

However I'm getting
Parse error: parse error, unexpected T_STRING in ....mobile.php on line 1

If I delete that <?xml line, everythings fine... I guess I don't need it, even though it's in all the examples I've seen... :/
 
Hmm, it didn't seem to make any difference! I tried uploading it to some real hosting and it even does the same there!

I even tried retyping the line incase the " was a strange character (copy/paste issues), but still the same. I guess I'll just have to use it without the xml line!
 
Back
Top Bottom