ipuck Posted August 27, 2006 Share Posted August 27, 2006 Hello: I have a file that receives information (variables X,Y,Z) from a link, searches a database and display results. No problem with that. Now I need to use that same information (X,Y,Z) and send it to another page. (A plain page for printing the data) [quote]$X = $_POST['value1']; $Y = $_POST['value2']; $Z = $_POST['value3']; echo ('Data information for variables'); echo ( $X $Y $Z); echo ('<a href="somefile.php?value1=$X&value2=$Y&value3=$Z">Print View</a>'); $strSQL = "SELECT table.* FROM table WHERE field1='X' AND field2='Y' AND field3='Z"; Rest of the file ' if else while ($row = ' [/quote] My problem is that is not no passing the information, in the link only shows: [quote]http://www.mysite.com/somefile.php?value1=$X&value2=$Y&value3=$Z [/quote] and not the value of the variables. What am I doing wrong? I use the same system to get the information in the first place. Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/18837-i-need-help-passing-information/ Share on other sites More sharing options...
wildteen88 Posted August 27, 2006 Share Posted August 27, 2006 You are using single quotes in your echo statement. PHP will treat your variables as-is and will not parse the the variables. Use double quotes or use the concatenation operator:Double quotes:[code=php:0]echo "<a href=\"somefile.php?value1={$X}&value2={$Y}&value3={$Z}\">Print View</a>"; [/code]Concatenation operator:[code=php:0]echo '<a href="somefile.php?value1=' . $X . '&value2=' . $Y . '&value3=' . $Z . '">Print View</a>'; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/18837-i-need-help-passing-information/#findComment-81294 Share on other sites More sharing options...
redarrow Posted August 27, 2006 Share Posted August 27, 2006 [code]<?php$x = $_POST['x']; $y = $_POST['y']; $z = $_POST['z']; echo "<a href='somefile.php?x=$x&y=$y&z=$z&cmd=print'>Print View[/url]"; ?>[/code] somfile.php[code]<?php$x=$_GET['x'];$y=$_GET['y'];$z=$GET['z'];if($_GET['cmd']=="print"){echo " $x <br> $y <br> $z ";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/18837-i-need-help-passing-information/#findComment-81299 Share on other sites More sharing options...
ipuck Posted August 28, 2006 Author Share Posted August 28, 2006 Thank you guys for your help!!I add a \ , like wildteen88 suggested and it worked.echo ("<a href= \" somefile.php?value1=$X&value2=$Y&value3=$Z \" >Print View</a>"); Thanks again!! Quote Link to comment https://forums.phpfreaks.com/topic/18837-i-need-help-passing-information/#findComment-81382 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.