PDA

View Full Version : How do I get a variable from a query string into PHP script?


matbury
02-27-2008, 01:57 PM
Hey guys,

Just getting into integrating Flash with PHP and MySQL and it's going pretty well so far.

My question is very basic. I want to take a variable from a URL query string and use it in a PHP script. Something like...

"http://yourserver.com/yourscript.php?variable=1"

...and use the variable in the PHP script on the page...

<?php
$variable = variable;
?>

This has gotta be one of the simplest and maybe dumbest questions ever, but your patience and help would be greatly appreciated! :)

Cota
02-27-2008, 02:41 PM
$variable = $_GET['Variablename']


Where 'Variablename" is the name of the variable in the query string

matbury
02-27-2008, 03:11 PM
Thanks Cota!

I though it'd be something incredibly simple like that. I can write the code to create DB tables and add and remove data but I couldn't get a simple value from a query string!

My next task is to get the info from the database indexed by the variable, which is the URL to an XML file, to pass into Flash.

Taking baby steps...

KingAdnan
03-03-2008, 11:08 AM
for example:
www.site.com/index.php?id=3

then it should be like this

<?
$var_from_url = $_GET['id'];

echo $var_from_url;

//will return 3

?>