2eXtreme Posted February 1, 2007 Share Posted February 1, 2007 Hey guys! Im having trouble sending variables to another php file. This is the code for the php file that sends the data: $number=2; $number2=3; header('Location:http://mysite.com/get.php?num=$number&num2=$number2'); the receiving file, get.php, is meant to receive the value of $number and ouput it to a .txt file. The code is: $digit = $_GET["num"]; $digit2 = $_GET["num2"]; $log = fopen("log.txt", "a"); fwrite($log, $digit."\n"); fwrite($log, $digit2."\n"); fclose($log); but all the log file contains is: $number $number2 When what I want to be seeing is: 2 3 Im guessing this comes down to how I've passed the variables in the sending file to the receiving file. Can anyone please tell me what I have to change? Thanks very much for any help given! Quote Link to comment https://forums.phpfreaks.com/topic/36693-passing-variables-only-variable-names-are-printed/ Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 Use: 'Location:http://mysite.com/get.php?num='.$number.'&num2=.'$number2 Quote Link to comment https://forums.phpfreaks.com/topic/36693-passing-variables-only-variable-names-are-printed/#findComment-174957 Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 it's because you are using single quotes instead of double quotes in your header function call. Single quotes interprets the variable names literally. If you want php to look at the variables as variables, use double quotes Quote Link to comment https://forums.phpfreaks.com/topic/36693-passing-variables-only-variable-names-are-printed/#findComment-174958 Share on other sites More sharing options...
2eXtreme Posted February 1, 2007 Author Share Posted February 1, 2007 Thank you so much! I knew it was about separting the variables up, like in Java and C, but using ',' and '+' didnt work, so I was totally stumped! Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/36693-passing-variables-only-variable-names-are-printed/#findComment-174960 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.