Mobile Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreMobile Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2007, 05:33 AM
andybarr2406 andybarr2406 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 andybarr2406 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 42 sec
Reputation Power: 0
Passing fields to PHP script

Hi all, this is my first post here and I am not a developer, so please be kind

Right I have been asked to reproduce a Cricket score web form on a WAP enabled device, abielt a bit simpler layout.

So firstly I created my WAP home Page

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "(URL address blocked: See forum rules)">

<wml>
  <card id="card1" title="BCL WAP Home">
    <p>Welcome to the BCL WAP Homepage</p>
	<anchor>
        <go href="#BCLPC"/>
        BCL Points Calculator
    </anchor><br/>
    <anchor>
        <go href="#BCLLT"/>
        BCL League Tables
     </anchor><br/>
  </card>
  <card id="BCLPC" title="BCL Points Calculator">
    <p>Please enter required information <br/>
      Team Batting First <br/>
      <input name="b1runs" maxlength="4" format="4N"/>
       Runs,for
      <input name="b1wickets" maxlength="2" format="2N"/>
      wickets, in
      <input name="b1overs" maxlength="2" format="2N"/>
      overs <br/>
      Team Batting Second <br/>
      <input name="b2runs" maxlength="4" format="4N"/>
       Runs,for
      <input name="b2wickets" maxlength="2" format="2N"/>
      wickets, in
      <input name="b2overs" maxlength="2" format="2N"/>
      overs <br/>      
      </p>
      <anchor>
        <go method="post" href="processform.php">
          <postfield name="b1runs" value="$(b1runs)"/>
          <postfield name="b1wickets" value="$(b1wickets)"/>
          <postfield name="b1overs" value="$(b1overs)"/>
          <postfield name="b2runs" value="$(b2runs)"/>
          <postfield name="b2wickets" value="$(b2wickets)"/>
          <postfield name="b2overs" value="$(b2overs)"/>
        </go>
        Submit Data <br/>
      </anchor>

      <anchor>
        <prev/>
        Going backwards
      </anchor>         
  </card>
  <card id="BCLLT" title="BCL League Tables">
    <p>In Development</p>
      <anchor>
        <prev/>
        Going backwards
      </anchor>    
  </card>

</wml>


Then I tried to convert the php backend script from the web version to produce the VML which looks like this

Code:
<?
header("Content-type: text/vnd.wap.wml"); 

// get data from form

$b1runs = $_POST['b1runs'];
$b1wickets = $_POST['b1wickets'];
$b1overs = $_POST['b1overs'];
$b2runs = $_POST['b2runs'];
$b2wickets = $_POST['b2wickets'];
$b2overs = $_POST['b2overs'];
$rain = $_POST['rain'];

//echo ("<br>rain value is $rain");

// Calculations

$b1runrate = $b1runs/$b1overs;
$b2runrate = $b2runs/$b2overs;

//echo ("<br>Side Batting first run rate is $b1runrate");
//echo ("<br> Side Batting second run rate is $b2runrate");

//Match Results

// Team Batting First

	Switch ( true )
	{
		case ($b1runs >= $b2runs) AND ($b1overs > $b2overs) AND ($b1runrate < $b2runrate) and ($b2wickets <> 10):
		$b1result = "Losing Draw";
		$b1matchpoints = 0;
		break;
		case ($b1runs >= $b2runs) AND ($b1overs < $b2overs) AND ($b1runrate > $b2runrate) and ($b2wickets <> 10):
		$b1result = "Winning Draw";
		$b1matchpoints = 0;
		break;
		case ($b1runs > $b2runs) AND ($b2wickets == 10) :
		$b1result = "Win";
		$b1matchpoints = 25;
		break;
		case ($b1runs > $b2runs) AND ($b2wickets < 10) :
		$b1result = "Winning Draw";
		$b2matchpoints = 0;
		break;
		case ($b1runs < $b2runs) :
		$b1result = "Lost";
		$b1matchpoints = 0;
		break;
		case ($b1runs == $b2runs) AND ($b2wickets == 10) :
		$b1result = "Tied Match";
		$b1matchpoints = 10;
		break;
		case ($b1runs == $b2runs) AND ($b1overs  == $b2overs) :
		$b1result = "Equal Draw";
		$b1matchpoints = 7;
		break;
		default:
		echo ("<br> Problem calculating result, Please check results!");
	}
// echo ("<br> Team Batting First $b1result");

// Team Batting Second

	Switch ( true )
	{
		case ($b1runs >= $b2runs) AND ($b1overs > $b2overs) AND ($b1runrate < $b2runrate) and ($b2wickets <> 10):
		$b2result = "Winning Draw";
		$b2matchpoints = 0;
		break;
		case ($b1runs >= $b2runs) AND ($b1overs < $b2overs) AND ($b1runrate > $b2runrate) and ($b2wickets <> 10):
		$b2result = "Losing Draw";
		$b2matchpoints = 0;
		break;
		case ($b1runs > $b2runs) AND ($b2wickets == 10) :
		$b2result = "Lost";
		$b2matchpoints = 0;
		break;
		case ($b1runs > $b2runs) AND ($b2wickets < 10) :
		$b2result = "Losing Draw";
		$b2matchpoints = 0;
		break;
		case ($b1runs < $b2runs) :
		$b2result = "Win";
		$b2matchpoints = 20;
		break;
		case ($b1runs == $b2runs) AND ($b2wickets == 10) :
		$b2result = "Tied Match";
		$b2matchpoints = 10;
		break;
		case ($b1runs == $b2runs) AND ($b1overs == $b2overs) :
		$b2result = "Equal Draw";
		$b2matchpoints = 7;
		break;
		default:
		echo ("<br> Problem calculating result, Please check results!");
	}
//echo ("<br> Team Batting Second $b2result");


//Batting Points

//Team Batting First
	Switch ( true )
	{
		case $b1runs >= 175 :
		$b1batpoints = 5;
		break;
		case $b1runs >= 150 :
		$b1batpoints = 4;
		break;
		case $b1runs >= 125 :
		$b1batpoints = 3;
		break;
		case $b1runs >= 100 :
		$b1batpoints = 2;
		break;
		case $b1runs >= 75 :
		$b1batpoints = 1;
		default:
		$b1batpoints = 0;
		break;
	}
//echo ("<br> Side Batting First's Batting Points is $b1batpoints");


//Team Batting Second
	Switch ( true )
	{
		case $b2runs >= 175 :
		$b2batpoints = 5;
		break;
		case $b2runs >= 150 :
		$b2batpoints = 4;
		break;
		case $b2runs >= 125 :
		$b2batpoints = 3;
		break;
		case $b2runs >= 100 :
		$b2batpoints = 2;
		break;
		case $b2runs >= 75 :
		$b2batpoints = 1;
		break;
		default:
		$b2batpoints = 0;
		break;
	}
//echo ("<br> Side Batting Second's Batting Points is $b2batpoints");

//Bowling Points

//Team Batting First
	Switch ( true )
	{
		case $b2wickets == 10 :
		$b1bowlpoints = 5;
		break;
		case $b2wickets >= 8 :
		$b1bowlpoints = 4;
		break;
		case $b2wickets >= 6 :
		$b1bowlpoints = 3;
		break;
		case $b2wickets >= 4 :
		$b1bowlpoints = 2;
		break;
		case $b2wickets >= 2 :
		$b1bowlpoints = 1;
		break;
		default:
		$b1bowlpoints = 0;
		break;
	}
//echo ("<br> Side Batting First's Bowling Points is $b1bowlpoints");

//Team Batting Second
	Switch ( true )
	{
		case $b1wickets == 10 :
		$b2bowlpoints = 5;
		break;
		case $b1wickets >= 8 :
		$b2bowlpoints = 4;
		break;
		case $b1wickets >= 6 :
		$b2bowlpoints = 3;
		break;
		case $b1wickets >= 4 :
		$b2bowlpoints = 2;
		break;
		case $b1wickets >= 2 :
		$b2bowlpoints = 1;
		break;
		default:
		$b2bowlpoints = 0;
		break;
	}
//echo ("<br> Side Batting Second's Bowling Points is $b2bowlpoints");

// Calculate Draw methods

	Switch ( true )
	{
		case $b1result == "Losing Draw" :
		$rundiff = ($b1runrate/$b2runrate)*100;
//		echo ("<br> 1. Runrate diff percentage is $rundiff");
		break;
		case ($b2result == "Losing Draw" ) AND ($b1overs == $b2overs) :
		$rundiff = ($b2runs/$b1runs)*100;
//		echo ("<br> 2. Runs diff percentage is $rundiff");
		break;
		case ($b2result == "Losing Draw" ) AND ($b1overs <> $b2overs) :
		$rundiff = ($b2runrate/$b1runrate)*100;
//		echo ("<br> 3. Runrate diff percentage is $rundiff");
		break;
		default:
		$rundiff = 0;
		break;
	}
	Switch ( true )
	{
		case $rundiff >= 95 :
		$ldrawpoints = 5;
		break;
		case $rundiff >= 90 :
		$ldrawpoints = 4;
		break;
		case $rundiff >= 85 :
		$ldrawpoints = 3;
		break;
		case $rundiff >= 80 :
		$ldrawpoints = 2;
		break;
		case $rundiff >= 75 :
		$ldrawpoints = 1;
		break;
		Default:
		$ldrawpoints = 0;
		break;
	}
//echo ("<br> Losing draw points is $ldrawpoints");

// Winning Draw Points

	Switch ( true )
	{
		case $b1result == "Winning Draw":
		$b1draw = 15 - $ldrawpoints;
		$b2draw = $ldrawpoints;
//		echo ("<br> Batting First Wining draw points $b1draw");
//		echo ("<br> Batting Second Losing draw points $b2draw");
		break;
		case $b2result == "Winning Draw":
		$b2draw = 15 - $ldrawpoints;
		$b1draw = $ldrawpoints;
//		echo ("<br> Batting Second Wining draw points $b2draw");
//		echo ("<br> Batting First Losing draw points $b1draw");
		break;
		default:
		break;
	}

// Bonus Bowling Points

	switch ( true )
	{
		case ($b1wickets == 10) AND ($b2result == "Win"):
		$b2bowlbonus = 5 - $b1bowlpoints;
//		echo ("<br> Bonus Bowling Points is $b2bowlbonus");
		break;
		default:
		break;
	}

// Total points 

// Team Batting First

	$b1TotalPoints = $b1bowlpoints + $b1batpoints + $b1matchpoints + $b1draw;
//	echo ("<br> Team batting First total points equals $b1TotalPoints");

// Team Batting Second
	$b2subTotalPoints = $b2bowlpoints + $b2batpoints + $b2matchpoints + $b2bowlbonus + $b2draw ;
	Switch ( true )
	{
		case $b2subTotalPoints > 30:
		$b2TotalPoints = 30;
		$b2limited = "*";
		$limittext = "* Points limited (30 points maximum for batting second)";
		break;
		default:
		$b2TotalPoints = $b2subTotalPoints;
		$b2limited = "";
		$limittext = "";
		break;
	}
//	echo ("<br> Team batting Second total points equals $b2TotalPoints");

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2005 by Francisco Burzi                                */
/* (URL address blocked: See forum rules)                                                   */
/*                                                                      */
/* Based on Feedback Addon 1.0                                          */
/* Copyright (c) 2001 by Jack Kozbial (jack@internetintl.com)           */
/* (URL address blocked: See forum rules)                                          */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

//if (!defined('MODULE_FILE')) {
//	die ("You can't access this file directly...");
//}

//require_once("mainfile.php");
//$module_name = basename(dirname(__FILE__));
//get_lang($module_name);

/**********************************/
/* Configuration                  */
/*                                */
/* You can change this:           */
/* $index = 0; (right side off)   */
/**********************************/
//define('INDEX_FILE', true);
//$subject = $sitename." "._FEEDBACK;
/**********************************/

/* define('NO_EDITOR', true);
include("header.php");

OpenTable();
$module_name = basename(dirname(__FILE__));	

echo "

<table border= \"1\">
<tr><th><td><td>Win/LosePoints<td>Draw Points<td>Batting Points<td>Bowling Points<td>Bonus Bowling Points<td>Total Points
<tr><th><td>Team Batting First<td><p align=\"center\">$b1matchpoints</p><td><p align=\"center\">$b1draw </p><td><p align=\"center\">$b1batpoints </p><td><p align=\"center\">$b1bowlpoints </p><td> <td><p align=\"center\">$b1TotalPoints </p>
<tr><th><td>Team Batting Second<td><p align=\"center\">$b2matchpoints </p><td><p align=\"center\">$b2draw </p><td><p align=\"center\">$b2batpoints </p><td><p align=\"center\">$b2bowlpoints </p><td><p align=\"center\">$b2bowlbonus<td><p align=\"center\">$b2TotalPoints $b2limited </p>
</table>

*/

echo "

<wml>
<card id="BCLRESULT" title="BCL Points Result">
<br> Team Batting First: $b1result with $b1TotalPoints points
<br> Team Batting Second: $b2result with $b2TotalPoints points $b2limited
<anchor>
<prev/>
Going backwards
</anchor>
</card>
</wml>
";


?>


The error I get is

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /homepages/6/d147840151/htdocs/bcl/wap/processform.php on line 353

line 353 is

<card id="BCLRESULT" title="BCL Points Result"> (at the end of the script

if anyone can see where I have gone wrong please can you post what I need to change.

Thanks

Andy
WML Newbie

Reply With Quote
  #2  
Old April 3rd, 2007, 06:16 AM
andybarr2406 andybarr2406 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 andybarr2406 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 42 sec
Reputation Power: 0
Found it

in the processform.php

Code:
echo "

<wml>
<card id="BCLRESULT" title="BCL Points Result">
<br> Team Batting First: $b1result with $b1TotalPoints points
<br> Team Batting Second: $b2result with $b2TotalPoints points $b2limited
<anchor>
<prev/>
Going backwards
</anchor>
</card>
</wml>
";


in the third line, " need a \ (\") to be read correctly and I need to remove the <br> as well

I hope that this helps someone out there

Reply With Quote
  #3  
Old April 7th, 2007, 06:29 PM
phpwebmaster phpwebmaster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 57 phpwebmaster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 8 m 16 sec
Reputation Power: 2
you shouldnt need to remove the <br> but because it is being parsed by PHP you should use <br /> instead.. least thats as much as i can gather

Reply With Quote
  #4  
Old April 7th, 2007, 08:50 PM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Click here for more information.
 
Join Date: Feb 2002
Location: Finland
Posts: 8,910 jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 4 Weeks 1 Day 11 h 24 m 59 sec
Reputation Power: 1693
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
This post has probably been sorted now,
but I will add to it since their was a response today.

@OP - you must escape the quotes for this to work.
2 ways detailed below. I prefer the second method.

Also, as stated <br> should be <br />, and your text should be in a container, <p> for example....
php Code:
Original - php Code
  1. <?php
  2.  
  3. <wml>
  4. <card id=\"BCLRESULT\" title=\"BCL Points Result\">
  5. <p>Team Batting First: $b1result with $b1TotalPoints points<br />
  6. Team Batting Second: $b2result with $b2TotalPoints points $b2limited
  7. </p>
  8. <anchor>
  9. <prev/>
  10. Going backwards
  11. </anchor>
  12. </card>
  13. </wml>
  14. ";
  15.  
  16. // OR
  17.  
  18. <wml>
  19. <card id="BCLRESULT" title="BCL Points Result">
  20. <p>Team Batting First: '. $b1result .' with '. $b1TotalPoints .' points<br />
  21. Team Batting Second: '. $b2result .' with '. $b2TotalPoints .' points '. $b2limited .'
  22. </p>
  23. <anchor>
  24. <prev/>
  25. Going backwards
  26. </anchor>
  27. </card>
  28. </wml>
  29. ';
__________________
Cheers,

Jamie

# mdb4u | mobile movie database] | Please help to test and promote
# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure

__________________

Let the might of your compassion arise to bring a quick end
to the flowing stream of the blood and tears .....
Please hear my anguished words of truth.



__________________

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreMobile Programming > Passing fields to PHP script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT