vasocreta Posted August 28, 2009 Share Posted August 28, 2009 Hi freaks! I am a bit beside myself on this one. I am trying to pass a variable via URL to another page. The issue is that the variable's value is a very ugly <object> complete with spaces and single quotes. I could really use a point in the right direction. Code: I have a variable: $link="<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='doc_771006427761711' name='doc_771006427761711' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' align='middle' height='500' width='100%' > <param name='movie' value='http://...etc, etc. IT GOES ON AND ON </object>"; In the same page, I output this variable in another variable as such: $mainContent = "<h1>TITLE</h1> <a href='http://SERVER PATH/link_fullView.php?link=$link'>LINK TO NEW PAGE</a><br /> <br /> $link"; Some of you already see the issue. In THIS page, I get $link outputted twice. When I click on the LINK TO NEW PAGE, the variable does not get passed correctly because of the spaces and the single quotes in the value. So, the issue seems to be the syntax in writing the value for the href. Any points in the right direction/solutions would be greatly appreciated. Sorry to be such a noob. But hey, we all start somewhere, right! Thanks in advance, everyone. Quote Link to comment https://forums.phpfreaks.com/topic/172224-trying-to-pass-a-variable-with-ugly-value-through-url-to-another-page/ Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 Well first if I were you, I'd open up your text editor and replace all the single quotes with double quotes, and nest it all in single quotes. If you're wanting to 'pass' it along with an url, then use urlencode functions naturally, to convert space to %20 etc and urldecode if needed. Edit: 'href='http://SERVER PATH/link_fullView.php?link=$link', you're trying to link the object code? huh? That's one of the most messiest things i've ever seen. Make it.. link=vid1_full.. and if isset($_GET['link']){ if ($_GET['link']=='vid1_full') { echo '<object...>....'; } } Quote Link to comment https://forums.phpfreaks.com/topic/172224-trying-to-pass-a-variable-with-ugly-value-through-url-to-another-page/#findComment-908045 Share on other sites More sharing options...
vasocreta Posted August 28, 2009 Author Share Posted August 28, 2009 Thanks for the response. What I am trying to do is allow the user to see an enlarged version of the embedded object. Due to the layout of the site, the embedded files (mainly PDFs) are rather small. Some users might want to see them full screen. So, I am putting an enlarge link above the embedded file that will open a new window with only the embedded file and no layout to constrain it. Does that make sense? Anyway, I was trying to use the same page, link_fullView.php, for all 11 embedded files. So, if I could pass the <object> from each of the pages where each PDF is embedded, I could simply reuse the code rather than create more documents and have multiple snips of the same ugly <object> code in two different files. So, now I will try to apply your suggestion. Thank you. I will post again if I get this working. Quote Link to comment https://forums.phpfreaks.com/topic/172224-trying-to-pass-a-variable-with-ugly-value-through-url-to-another-page/#findComment-908049 Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 Well yeah, it'd be better to have $_GET's set up so you can view all the documents the way you wanted.. viewpdf.php?pdf=foo viewpdf.php?pdf=foo&fullscreen=true.. All you need is that one page, and simple $_GET and if statements to echo the <object> codes for each one.. no passing.. no ugly writing etc.. you can even go as simple as.. <object embed=".$_GET['pdf']." fullscreen=".$_GET['fullscreen']."> etc.. Quote Link to comment https://forums.phpfreaks.com/topic/172224-trying-to-pass-a-variable-with-ugly-value-through-url-to-another-page/#findComment-908062 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.