PHP with WML problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian A

    PHP with WML problem

    I have tried the script below as a test and named it test.wml
    ............... ...........
    <?php
    /* Some not needed php vars for example */
    $page_name ='Test';
    $page = '<p>This is the page content</p>';
    /* Header stuff */
    header('Content-Type: text/vnd.wap.wml', true);
    header('Cache-Control: no-cache, must-revalidate');
    header('Pragma: no-cache');

    print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
    /* Exit PHP and print out wml doc
    save as *.php
    */
    ?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.or g/DTD/wml_1.1.xml">
    <wml>
    <card id="Page<?php echo $page_name; ?>" title="<?php echo $page_name;
    ?>">
    <p>
    <strong><?php echo $page_name; ?></strong>
    </p>
    <?php
    echo $page;
    ?>
    <p><br />
    <anchor>Home
    <go href="/" />
    </anchor>
    <do type="prev" label="Back"><p rev/></do>
    </p>
    </card>
    </wml>
    ............... ............... ............... .......

    I have used the following in a .htaccess file

    ............... ............... ............... ...........
    # For PHP 4.x :
    AddType application/x-httpd-php .wml
    ............... ............... ............... ............

    The .htaccess is doing something because I have no success without it.

    I am using the openwave 6.2.2 SDK viewer/emulator to test the script
    along with a Nokia 7210


    These are the results:

    1. Using my own local server - Script OK on Openwave.
    2. Using my Net webspace - Openwave reports an error, for all three of
    the PHP header command lines,

    'Headers already sent' - If I remove the PHP header commands it works
    perfectly.
    3. Tried the script from my Net web site on the Nokia 7210 - headers
    included or not the 7210 reports

    'unknown format' and doesn't attempt to do anything.

    So what is going wrong and how can I solve this problem?
    Remove 'no_spam_' from email address.
  • Gordon Burditt

    #2
    Re: PHP with WML problem

    >I have tried the script below as a test and named it test.wml

    If you wish to send headers, you must send *NOTHING* before the headers.
    [color=blue]
    >.............. ...........
    > <?php[/color]
    ^^ I see two spaces here, outside the <?php ... ?> part.
    [color=blue]
    >/* Some not needed php vars for example */
    >$page_name ='Test';
    >$page = '<p>This is the page content</p>';
    >/* Header stuff */
    >header('Conten t-Type: text/vnd.wap.wml', true);
    >header('Cach e-Control: no-cache, must-revalidate');
    >header('Pragma : no-cache');
    >
    >print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";[/color]
    ....[color=blue]
    ># For PHP 4.x :
    >AddType application/x-httpd-php .wml
    >.............. ............... ............... ............
    >
    >The .htaccess is doing something because I have no success without it.[/color]
    If you want it processed as PHP, you need this, or something equivalent.
    [color=blue]
    >
    >I am using the openwave 6.2.2 SDK viewer/emulator to test the script
    >along with a Nokia 7210
    >
    >
    >These are the results:
    >
    >1. Using my own local server - Script OK on Openwave.
    >2. Using my Net webspace - Openwave reports an error, for all three of
    >the PHP header command lines,
    >
    >'Headers already sent' - If I remove the PHP header commands it works
    >perfectly.[/color]

    This is a clue that you are sending junk before the headers.
    A blank line or a single space is enough to cause trouble.

    Gordon L. Burditt

    Comment

    Working...