PHP:don't know how to insert object into $var

Status
Not open for further replies.

gohand

In Runtime
Messages
151
Here is my problem, i wanted to set input a flash movie or .swt file into a variable in php, for example i want to insert this
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="550" height="400">
<param name="movie" value="../library/movie.swf">
<param name="quality" value="high">
<embed src="../library/nd.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed>
</object>

into variable $movie, i'll put $movie=" the line quoted above "; but it returned me many errors. like parse error and file cannot find error, so i found out it's the problem with the quotes, but i almost tried anyway i can to put it, it still don't work, because the movie object had too many """s so i tried to use 'Movie objects' then my movie is able to displayed, but there is so many warnings, then i found out that after i place ' ' quote out side of " " quote the " " quote inside just disfuntioning. So all i wanted to do is to replace that $movie with the movie object, please help. Thanks in advence!
 
put a backslash (\) before each double-quote ("). So to encode:
a "string" with double quotes
write:
"a \"string\" with double quotes"
That should solve the problem
 
It shows the same error message as before, but that should help tho, maybe i done something wrong, here's what i've did:
$movie= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"640\" height=\"340\">
<param name=\"movie\" value=\"/library/reel.swf\">
<param name=\"quality\" value=\"high\">
<embed src=\"/library/reel.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"640\" height=\"340\"></embed>
</object>";

it shows me as the way i did with 'a "string" with double quotes'

thanks a lot~
 
Let me get clear what you want to do. Do you want the code to go into a variable so PHP can output it into HTML or do you want PHP to "know" what the object is and do something with it. I don't know if the latter is in fact possible.
 
here is the basic structure of my site:
//i want an object to store inside of a variable so when the condition gets to it, it'll replace the content within a table

definistion.....
if($select==a){
$content="......";
}
if($select==b){
$content="the flash movie to be displayed";//this is where it don't work}
...
...
//within a table
<table>
include ($content)
</table>

this is what i wanted it to do. thx
 
What it seems to me is happening (I could well be wrong) is that include () is interperting its argument as a file whose contents it should drop into the code and instead is getting the contents itself, in a forat that may be an invalid filename. Try using print () instead; that will simply insert its parameter into the HTML.
 
wow thanks it finally works! but now it came another problem, now that i replaced the include ($content) as print ("$content"); and replaced other condition into $content= include (...); but the content is printing out side of the table instead of inside, and printed "1" inside of the table, tho the object thing does fine, so this time what have i done wrong?
 
as follows to the post before my last post, it stated the original code's structure was a $content variable withing a table, and within the table was include($content); now that i've changed it acording to your suggestion, to as: print($content) instead of include ($content), so now it works! But it's only for the flash object, but the other conditionals(if) that refer to other case of the $content would be defined, was originaly as a url location for it to include, so now the url is printed instead of the url's content, in order to fix this, i replace the url(on the line of the conditional) to include(url) etc. but what's weird that printed out was that the content was out side of the table(above every table), but in fact the flash object is fine, and in exactly where i wanted it to be. how can i fix it?
 
That makes sense $content=include (url); will put the return value of include into content, (1 for sucess) and print () nwill just output that.

The cleanest solution I can think of is this:

Create a super file that calls print () or one include () according to a URL parameter. Then in the if just set $variable to some value showing what's been selected. Then in the table just include () the super file, passing it the url with $variable as a URL parameter.
 
Status
Not open for further replies.
Back
Top Bottom