SunQuest
           WAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreWAP 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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old November 30th, 2004, 08:26 AM
twistedtwig's Avatar
twistedtwig twistedtwig is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Horsham - England
Posts: 302 twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 4 h 34 m 19 sec
Reputation Power: 22
Unhappy passing variables from one card to another and using an sql query???

hey all,

not 100% sure if this should go in the wap or PHP section but thought it could be this one, sorry if i was wrong.. here goes anyway....

i have a problem with my code:

Quote:
<?php
header('Content-Type: text/vnd.wap.wml', true);
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Search For Film">
<p align="center"> <img src="logo2.wbmp" alt="Logo"/><br/>
stuff i have on video and dvd </p>

<do type="accept" label="Find">
<go href="#cardResult" />
</do>
<p>
FilmName: <input name="name" type="text"/><br/>
</p>
</card>

<card id="cardResult" title="Film results">
<p><font size="-6">Film: </font><br/>
<?php

$filmdb = mysql_connect("localhost", "YYY"QQQ");
$db = mysql_select_db("XXX",$filmdb);

$testvar = "$(name)";

$query = "select * from films where FilmName like '%$testvar%'";
$result = mysql_query($query);
if($result):
if(mysql_num_rows($result) > 0 ):
while($row = mysql_fetch_array($result)):
echo "$row[FilmName] <br/>";
endwhile;
mysql_free_result($result);
endif;
else:
echo "No results found for $(mine)";
endif;

echo "$(name)";
echo "$testvar";

mysql_close($filmdb);
?>
</p>
</card>
</wml>


the problem is that i cant get the results to display. i am trying to get teh input from the user from teh input box called "name" and pass that into the sql query.. i wasnt having any luck at all so thought id try and put it into a normal variable and pass that into the query.

$testvar = "$(name)";

this didnt help at all.. the sql query works because i can hard code a result like %pay% and it will return a few results but with the variables it wont work.

i put some echos at the bottom to see if the variables held the input and it did.

i am completely confused.. any advice would be grand..
thx

Jon

Reply With Quote
  #2  
Old November 30th, 2004, 01:51 PM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,667 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th 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 3 Weeks 4 Days 5 h 1 m 49 sec
Reputation Power: 1618
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
I cheat when it comes top wml and use PHP variables. try this - (untested), not sure whether this would work posting to a card in the original deck but give it a go and see what happens. You were missing post field or method -may have caused the problem - if you just used get method, then still use php to capture the result: $_GET['name']
PHP Code:
<?php
// snip
<do type="accept" label="Find" method=post">
<go href="
#cardResult" />
<postfield name="name" value="$name" /> 
</do>
<
p>
FilmName: <input name="name" type="text"/><br/>
</
p>
</
card>
// snip
$testvar $_POST['name'];
// snip
?>
__________________
Cheers,

Jamie


# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure

# Any form of employment is strictly prohibited ......


__________________

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
  #3  
Old November 30th, 2004, 05:19 PM
twistedtwig's Avatar
twistedtwig twistedtwig is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Horsham - England
Posts: 302 twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level)twistedtwig User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 4 h 34 m 19 sec
Reputation Power: 22
Unhappy Confused

thx for the advice,

i am having a new problem now its a bit werid... the code FULLY works on an online emulator, http://www.wapsilon.com/ , but wont run on my mobile.. wont even load now.. says "unsupported type" i know the database connection is good as it works on teh emulator and the html version works fine.. the emulator will run it perfectly.. but not on my phone, the phone is a samsung e700 btw. i tried wapalizer or something similar to that name and the first page loads, which is more than my mobile, but it wont action the query part of the script. here is my full and changed code:

Quote:
<?php
header('Content-Type: text/vnd.wap.wml', true);
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Search For Film">
<p align="center"> <img src="logo2.wbmp" alt="Logo"/><br/>
stuff i have on video and dvd </p>

<do type="accept" label="Find" >
<go href="#cardResult" method="post">
<postfield name="name" value="$name" />
</go>
</do>
<p>
FilmName: <input name="name" type="text"/><br/>
</p>
</card>

<card id="cardResult" title="Film results">
<p><font size="-6">Film: </font><br/>
<?php

$filmdb = mysql_connect("localhost", "YYY", "ZZZ");
$db = mysql_select_db("XXX",$filmdb);

$testvar = $_POST['name'];

$query = "select * from films where FilmName like '%$testvar%'";
$result = mysql_query($query);
if($result):
if(mysql_num_rows($result) > 0 ):
while($row = mysql_fetch_array($result)):
echo "$row[FilmName] <br/>";
endwhile;
mysql_free_result($result);
endif;
else:
echo "No results found for $testvar";
endif;

mysql_close($filmdb);
?>
</p>
</card>
</wml>


i really dont ahve a clue whats going on to make it work on one place and not on another it doesnt make much sense to me, i know i am new to this stuff but its frying my brain.

any ideas plz?

Jon

Reply With Quote
  #4  
Old December 1st, 2004, 01:44 AM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,667 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th 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 3 Weeks 4 Days 5 h 1 m 49 sec
Reputation Power: 1618
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
Try running the final outputted code through a validator.
Good way to check this locally is to use Firefox browser with the wml browser extension or Opera -> this will output the final source code regardless and it show errors.

J

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > getting my variables to work with each other


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 6 hosted by Hostway