Forum Moderators: coopster

Message Too Old, No Replies

I need help passing information

         

puckparches

7:48 pm on Aug 27, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



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)

$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 =
'

My problem is that is not no passing the information, in the link only shows:

[mysite.com...]

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

BarryStCyr

8:29 pm on Aug 27, 2006 (gmt 0)

10+ Year Member



You need to use Double Quotes (") instead of Single Quotes (').

echo ("<a href=\"somefile.php?value1=$X&value2=$Y&value3=$Z\">Print View</a>");

In PHP strings in single quotes don't expand variables.

Hope this helps.
Barry

[edited by: BarryStCyr at 8:33 pm (utc) on Aug. 27, 2006]

puckparches

9:30 pm on Aug 27, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you BarryStCyr!

It didn't work :(. I still don't understand why is not working, I can display the value of the variables, but I can't pass it.?.

Thank you!

BarryStCyr

9:57 pm on Aug 27, 2006 (gmt 0)

10+ Year Member



Did you escape the inner quotes with a \

echo ("<a href=

\"
somefile.php?value1=$X&value2=$Y&value3=$Z
\"
>Print View</a>");

[edited by: BarryStCyr at 9:57 pm (utc) on Aug. 27, 2006]

dreamcatcher

10:58 pm on Aug 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi puckparches,

Set your error reporting level to E_ALL at the top of your script, this may help with debugging.

error_reporting(E_ALL);

As BarryStCyr pointed out, double quotes allow you to parse a string without quoting variables. With your original string you would need:

echo '<a href="somefile.php?value1='.$X.'&value2='.$Y.'&value3='.$Z.'">Print View</a>';

dc

puckparches

12:53 am on Aug 28, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



Yes and it didn't worked. Then you ask me if I have used "\", I was sure I did, but I tested again anyway, and guess what it worked.

Thank you very much for your help.