POST Variables to function
Posted: Sat May 23, 2009 10:41 am
I'm calling in variables using
I want to use these throughout my script including in a function:
The variable is not passing to the function. I know this is a bonehead question, and I've googled a solution ad nauseam to no avail. I'm a pseudo-newbie to php, so be kind. I've tried declaring as global both inside and outside of the function ($name=$_POST['name']; global $name;). I've tried passing them as parameters to the function (ie function helloworld($name, $address)). Nothing's working. I know the variables are passing to the script because they work fine outside of the function.
Thanks in advance -
sleepydad
Code: Select all
$name=$_POST['name'];
$address=$_POST['address'];
Code: Select all
function helloworld() {
$db=new mysqli(' ', ' ', ' , "$name");
$result=$db->query($query);
/*
stuff
here
and
here
*/
$db=new mysqli(' ', ' ', ' , "$address");
$result=$db->query($query);
}
Thanks in advance -
sleepydad