Page 1 of 1

askin about function ..

Posted: Tue Sep 08, 2009 5:19 am
by tito63
hi evry body
i have a big problem :oops:
i want to get a variable value from inside a function to out side

Code: Select all

 
function work($name){
global $db_prefix;
$query = mysql_query("select * from `" .$db_prefix. "addons` where name ='" .$name . "'");
$array = mysql_fetch_array($query);
$array = $array['work'] ;
return $name ;
}
 
the variable is $array
i want to use it out side for example

Code: Select all

 
function work($name){
global $db_prefix;
$query = mysql_query("select * from `" .$db_prefix. "addons` where name ='" .$name . "'");
$array = mysql_fetch_array($query);
$array = $array['work'] ;
return $name ;
}
 
echo $array ;

or

Code: Select all

 
function work($name){
global $db_prefix;
$query = mysql_query("select * from `" .$db_prefix. "addons` where name ='" .$name . "'");
$array = mysql_fetch_array($query);
$array = $array['work'] ;
return $name ;
}
 
if ($array == 1){
echo "done";
}
pleaseeeeeee help me if u can :roll:

and i dont know if my post in the right section or not but i'm sorry

waiting for you :D

Happy day

Re: askin about function ..

Posted: Tue Sep 08, 2009 5:27 am
by Mark Baker
return $array;

Re: askin about function ..

Posted: Tue Sep 08, 2009 5:31 am
by tito63
thank u so match
but it didn't work :cry:

Re: askin about function ..

Posted: Tue Sep 08, 2009 5:34 am
by onion2k
It's the right answer. Try it again, but this time read the PHP manual page for "return" first. http://us2.php.net/manual/en/function.return.php

Re: askin about function ..

Posted: Tue Sep 08, 2009 5:39 am
by Mark Baker
Evens the OP isn't assigning the result of the call

Code: Select all

 
function work($name){
global $db_prefix;
$query = mysql_query("select * from `" .$db_prefix. "addons` where name ='" .$name . "'");
$array = mysql_fetch_array($query);
$array = $array['work'] ;
return $array;
}
 
$result = work('ABC');
echo $result;
 

Re: askin about function ..

Posted: Tue Sep 08, 2009 5:50 am
by tito63
thank you very vary match
it work's
thank you agine