Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    21

    Unanswered: WML PHP and MySQL

    I am trying to access a database through a cell phone. First page you enter a name to search for. This returns results on a second page.

    I am able to enter a search name and it returns incorrect results from the database because for some reason the input parameter is not getting passed from the main wml page to the php code.

    Here is the first page

    Code:
    <?php
    
    Header("Content-type: text/vnd.wap.wml");
    Header("Cache-Control: no-cache, must-revalidate");
    Header("Pragma: no-cache");
    echo ("<?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="SaintSearch">
    <p> 
      <do type="accept">
      <go href="index2.php" method="post">
    	<postfield value="$skier"/>
    
      </go>
      </do>
      Name: <input title="Name" name="skier"/>
    
    </p>
    </card>
    </wml>

    HERE IS THE PHP page

    Code:
    <?php
    
    Header("Content-type: text/vnd.wap.wml");
    printf("<?xml version=\"1.0\"?>\n");
    printf("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" "
            ."\"http://www.wapforum.org/DTD/wml_1.1.xml\" >\n");
    printf("<wml>\n");
    
    ?>
    	<wml>
    	<card id="index2" title="sql">
    	<?php
    	@ $db = mysql_pconnect('localhost', 'xxx', 'xxxxx');
    
    	if (!$db)
    	{
    		echo 'Error: Could not connect to database. Please try again later.';
    		exit;
    	}
    
    	mysql_select_db('saintData') or die (mysql_error()."<br />Couldn't select database"); 
    
    	$query = "select lastname, firstname from skiers where (firstname like '%$chicken%' or lastname like '%$skier%') AND (is_hidden = '0')";
    
    	$result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query"); 
    	
        	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            	print $row["lastname"]."<br>\n";
            }
    
    
    	mysql_free_result($result);
    	
    	?>
    	</card>
    	</wml>
    please forgive me, I am new at all of this.

  2. #2
    Join Date
    Jun 2004
    Posts
    11
    I'm not all that familiar with WML but the first thing I'd do is change the following line in your PHP page from ....

    Code:
    $query = "select lastname, firstname from skiers where (firstname like '%$chicken%' or lastname like '%$skier%') AND (is_hidden = '0')";
    to....

    Code:
    $query = "SELECT `lastname`, `firstname` FROM `skiers` WHERE (`firstname` LIKE '%${chicken}%' or `lastname` LIKE '%${skier}%') AND (`is_hidden` = '0')";
    Then i'd use PHP's print_r() function to print out $_REQUEST and see what data is being passed from the WML page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •