Helpful Information
 
 
Category: Mobile Programming
Creating WAP pages with PHP

I am busy developing a site that will need to be accessed by both WAP and normal browsers. The normal browser access is OK and the site is finished for that - now comes to big problem:

I need to create content based on a MySQL database for use on WAP, my only means of accessing the MySQL db is using PHP from a Linux server. I've tried a test that is supposed to display Hi on the WAP browser. This does not work it gives me the following error:
Unsupported content type: text/html
The code below is the original code I tried. After that I included Header("Content-type: text/wml"); with Content-type changing from text/wml to text/xml to xml to wml to xml/wml to no avail.

<?

print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">

<wml>
<template>
<do type=\"options\" name=\"prev\" label=\"Back\">
<prev/>
</do>
</template>
<card title=\"Page Title\" id=\"first\">
<p align=\"center\">Hi</p>
</card>
</wml>
";

?>

Your help would be greatly appreciated

you want something more like this....

<?
header("Content-type: text/vnd.wap.wml");
echo("<?xml version=\"1.0\"?>\n");
echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
." \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
?>

<wml>
<template>
<do type="options" name="prev" label="Back">
<prev/>
</do>
</template>
<card title="Page Title" id="first">
<p align="center">Hi</p>
</card>
</wml>


The stuff inbetween the <? ?> is php, outside is WML. Not the line that reads
header("Content-type: text/vnd.wap.wml");
This tells the client browser that WML follows. Note - you'll need a wml browser to view your pages.

Thanks topls64 - now I can finish (at last)

Just note the bottom have of the example I gave was in wml. You can, however, output the wml via php, like this....




echo "<card id=\"results\" title=\"Search\">\n"
. " <p>\n"
. " Your search for \"<b>" . stripslashes($seQuery) . "</b>\" returned no results. "
. "Use the back button to try again.\n"
. " </p>\n"
. "</card>\n"



This allows you to add variables, etc....

Figured that.

Thanks anyway

Hi,

How do i view the pages ? Also do i name the pages as mypage.wml or mypage.php ? I am on CPanel based server and I have same issues. I have now created a sample page using the code provided above but i don't know what extension to give it ? Please help.

Thanks.

Hi kikloo, welcome to Devshed!

In future please do not dig up posts that are this old -
please use a bit of common sense.
Your questions aren't even relevant to the original post..

Anyway, to answer your questions:
1: How do i view the pages ? FAQ #5
2: Also do i name the pages as mypage.wml or mypage.php -up to you, provided that you can get your server to parse .wml as php it doesn't matter
3: I am on CPanel based server and I have same issues. Probably your php isn't working if you are using short_tags (<?) -
see recent threads in the PHP forum about this: one to get you started

WAP is not that useful these days anyway,
you may want to investigate XHTML MP, see WAP Resources for more info.

HTH and good luck.










privacy (GDPR)