sh0wtym3 Posted October 24, 2008 Share Posted October 24, 2008 Hey all, The following code works with the "echo" command (towards bottom of code): <?php if($_GET["cmd"]=="play") { $track = $_GET['track']; $track2 = substr($track, 0, strripos($track, '.')); // strip mp3 extension $ourFileName = "$track2.xml"; //add xml extension $xmlload = "$track2.xml"; //variable which will be placed in the header link $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); $stringData =<<<HTML <config> <param name="mp3" value="$track" /> <param name="width" value="300" /> <param name="height" value="30" /> <param name="sliderwidth" value="30" /> <param name="sliderheight" value="16" /> <param name="buttonwidth" value="30" /> <param name="bgcolor" value="cccc99" /> <param name="bgcolor1" value="0000ff" /> <param name="bgcolor2" value="ff0000" /> <param name="showvolume" value="1" /> <param name="volumewidth" value="50" /> <param name="volumeheight" value="10" /> </config> HTML; fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); echo "<a href=test3.php?cmd=play&xml=$xmlload>Click to Continue</a>"; } I don't want users to have to click "Click to Continue" every single time this page is displayed, so I changed the echo to a header: <?php if($_GET["cmd"]=="play") { $track = $_GET['track']; $track2 = substr($track, 0, strripos($track, '.')); // strip mp3 extension $ourFileName = "$track2.xml"; //add xml extension $xmlload = "$track2.xml"; //variable which will be placed in the header link $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); $stringData =<<<HTML <config> <param name="mp3" value="$track" /> <param name="width" value="300" /> <param name="height" value="30" /> <param name="sliderwidth" value="30" /> <param name="sliderheight" value="16" /> <param name="buttonwidth" value="30" /> <param name="bgcolor" value="cccc99" /> <param name="bgcolor1" value="0000ff" /> <param name="bgcolor2" value="ff0000" /> <param name="showvolume" value="1" /> <param name="volumewidth" value="50" /> <param name="volumeheight" value="10" /> </config> HTML; fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); header ('Location: test3.php?cmd=play&xml=$xmlload'); } However, this does not work because the user is redirected to http://www.mysite.com/test3.php?cmd=play&xml=$xmlload It should display the $track2.xml value in the URL instead of $xmlload. For some reason the correct URL is used when you click on the link in the echo statement, but not when I try to use header...? How can I fix this? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/130017-solved-php-header-wont-recognize-variable/ Share on other sites More sharing options...
rhodesa Posted October 24, 2008 Share Posted October 24, 2008 use double quotes, not single quotes. variables don't get evaluated inside single quotes Link to comment https://forums.phpfreaks.com/topic/130017-solved-php-header-wont-recognize-variable/#findComment-674105 Share on other sites More sharing options...
sh0wtym3 Posted October 25, 2008 Author Share Posted October 25, 2008 Thanks! Works! I should start paying you this is the 2nd time you've helped me lol Link to comment https://forums.phpfreaks.com/topic/130017-solved-php-header-wont-recognize-variable/#findComment-674130 Share on other sites More sharing options...
rhodesa Posted October 25, 2008 Share Posted October 25, 2008 for help like this, donations to the site are always welcome... ...if you ever need an actual project worked on, you know how to reach me Link to comment https://forums.phpfreaks.com/topic/130017-solved-php-header-wont-recognize-variable/#findComment-674135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.