Jump to content

Trying to pass a variable with ugly value through url to another page


Recommended Posts

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.

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...>....';
}
}

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.

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..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.