askin about function ..

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
tito63
Forum Newbie
Posts: 3
Joined: Tue Sep 08, 2009 5:10 am

askin about function ..

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: askin about function ..

Post by Mark Baker »

return $array;
tito63
Forum Newbie
Posts: 3
Joined: Tue Sep 08, 2009 5:10 am

Re: askin about function ..

Post by tito63 »

thank u so match
but it didn't work :cry:
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: askin about function ..

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: askin about function ..

Post 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;
 
tito63
Forum Newbie
Posts: 3
Joined: Tue Sep 08, 2009 5:10 am

Re: askin about function ..

Post by tito63 »

thank you very vary match
it work's
thank you agine
Post Reply