PHP noob needing assistance

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
2Tall
Forum Newbie
Posts: 5
Joined: Wed Nov 22, 2006 8:21 pm

PHP noob needing assistance

Post by 2Tall »

Hey, I need to make a simple PHP page. I know my web server supports PHP and all, but I was just hoping to get this wrapped up with you guys right quick:

I basically want a page that is like so:

http://www.mydomain.com/index.php?variable=MyInfo

which would end up taking "MyInfo"

and sticking it into the page like so

<EMBED SRC="www.mydomain.com/supercool.SWF?customdata=<?php $variable> quality="high">

...I know that isn't how you do it. To make MyInfo the customdata passed into the Flash SWF...

so how do I do this?

thx :D
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

echo "<EMBED SRC=\"www.mydomain.com/supercool.SWF?customdata=".$_GET['variable']."\" quality=\"high\"> ";
2Tall
Forum Newbie
Posts: 5
Joined: Wed Nov 22, 2006 8:21 pm

Post by 2Tall »

...thanks! And should "variable" be empty, is there an easy way to make it something by default?

maybe PHP earlier in the code, would it be like...

<?php if $variable == "" { variable = "Default" }>

anything like that? :X

thanks again, much appreciated
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

$variable = (isset($_GET['variable']) && $_GET['variable'] != "" ? $_GET['variable'] : "somedefaultvalue");
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

$variable = empty($_GET['variable']) ? 'default' : urlencode($_GET['variable']);

echo "<EMBED SRC=\"www.mydomain.com/supercool.SWF?customdata=".$variable."\" quality=\"high\"> ";
Last edited by John Cartwright on Wed Nov 22, 2006 8:40 pm, edited 2 times in total.
2Tall
Forum Newbie
Posts: 5
Joined: Wed Nov 22, 2006 8:21 pm

Post by 2Tall »

i'll look for the bill in the mail ;)

thx
2Tall
Forum Newbie
Posts: 5
Joined: Wed Nov 22, 2006 8:21 pm

Post by 2Tall »

I'm fimiliar with IF, THEN, etc type statements...

but could you please explain to me "in english" what the

variable = (something) ? (stuff) : (stuff)

means?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

A previous thread that's directly related: viewtopic.php?t=56869
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
2Tall
Forum Newbie
Posts: 5
Joined: Wed Nov 22, 2006 8:21 pm

Post by 2Tall »

I've been screwing with this, but it always throws syntax error... any assistance appreciated then I have this project knocked :)

thanks :)

Help repair, please:

Code: Select all

echo ($fetchme = "") ? "<IMG SRC=\"www.mydomain.com/cool.jpg/"> : <EMBED SRC=\"http://www.mydomain.com/awesome.swf?playerName=".$_GET['fetchme']."\" quality=\"high\" height=\"145\" width=\"470\" border=\"0\"> ;
basically looking for, if $fetchme is empty, show the jpg, otherwise, show the flash with the fetchme supplied data

:) thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You are either missing or have misplaced quotes.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

also, you're not using the comparison operator for $fetchme (==)...that won't throw a syntax error, but it also won't give you the results you desire.
Post Reply