Reply
Noobie problem on print command :o
Old 01-29-2005, 06:41 AM Noobie problem on print command :o
SNP
Junior Talker

Posts: 4
Hello, I'm new here and in the whole PHP world

I hit a wall trying to make a small script. I actually followed some tutorials and resulted in a problem. I want to pass on some Variable Values throu a Hidden Form type to another page and well I have the following prob

PHP Code:
 print  "<table align='center' border='1' cellpadding='0'><tr><td>
        <form method='post' action='final.php'>
        <input type='submit' name='keybutton' value='Show Key'></td></tr>"
;
print  
"<input type='hidden' name='title' value='$title'>";
print  
"<input type='hidden' name='makekey' value='$makekey'></form>"
I hoped that with these lines (lines are on the wordgame.php page) I could pass on the information of $title and $makekey to final.php through an Hidden Form type.

However , the line:
PHP Code:
 print  "<input type='hidden' name='makekey' value='$makekey'></form>" 
seems to print out my $makekey value (even printing out the " '> " afterwards) on the wordgame.php while I do not have the same problem with the $title which is one line above.

Don't know what I'm doing wrong.

PS. I haven't moved on to MySQL thats why I'm using this method. Sorry, I'm noob
SNP is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-29-2005, 07:25 AM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Hey SNP,

As your code stands now you are printing out to the text document.
print 'ect...'; is all text.
print $makekey; is all variable.

So we have to compromise


print "<input type='hidden' name='makekey' value='".$makekey."'></form>"

Give that a go


P.S Were is makekey's value comming from?
__________________
CYTech-services.com - 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 01-29-2005, 07:52 AM
SNP
Junior Talker

Posts: 4
Well it's a bit more complex than a simple value.

First of all:
PHP Code:
 $makekey=drawBoard($key); 
The drawBoard fuction code is:
PHP Code:
function drawBoard($board)
{
global 
$boardD,$title;

$puzzle="";
$puzzle.="<table align='center'  border='0' cellpadding='5' cellspacing='5'><caption><h3>$title</h3></caption>";
for (
$i=0;$i<$boardD['height'];$i++){
    
$puzzle.="<tr><font align='center'>";
    for (
$j=0;$j<$boardD['width'];$j++){
        
$puzzle.="<td><center>{$board[$i][$j]}</center></td>";
    }
    
$puzzle.="</tr></font>";
    }
    return 
$puzzle;

I also tried giving $makekey an easy value such as "lalala" and I didn't have the same problem. (It didn't print lalala on the wordgame.php page)

Will try and figure out if the error is somewhere else in the code. Until now I only though I had sth wrong with the escape code.

Thanx for replying


PS. I tried the approach you noted ACJavascript by using :
PHP Code:
 print  "<input type='hidden' name='makekey' value="'.$makekey.'"></form>"
Which returned a parse error. Tried it like this:
PHP Code:
 print  "<input type='hidden' name='makekey' value=".'$makekey'."></form>"
But had the same results as if I had used print ' ' , instead of " ". (variables didn't parse)

Last edited by SNP : 01-29-2005 at 07:59 AM.
SNP is offline
Reply With Quote
View Public Profile
 
Old 01-29-2005, 11:21 AM
Republikin's Avatar
Super Moderator

Posts: 3,191
Syntacticly your code is correct, however try this just to humour me.

PHP Code:
print  "<input type=\"hidden\" name=\"makekey\" value=\"$makekey\"></form>"
Republikin is offline
Reply With Quote
View Public Profile
 
Old 01-29-2005, 12:50 PM
SNP
Junior Talker

Posts: 4
It actually worked cptnwinky !!! Thanx!
SNP is offline
Reply With Quote
View Public Profile
 
Old 01-29-2005, 03:40 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
Glad to be of service.
Republikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Noobie problem on print command :o
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13917 seconds with 12 queries