Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Returning Variables from a different function
Old 05-25-2009, 09:56 AM Returning Variables from a different function
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hey everyone,

I was just wonder how I would send a variable from one function to another.
eg.
PHP Code:
$test =' '.$this->getMaxItemCost($armymodel).' ';

function 
getMaxItemCost($armymodel) {
    
$sql_text "SELECT id, maxitemcost FROM ".$this->TABLES['currentarmy']." WHERE id = '$armymodel'";
    
$data $this->sql->Select($sql_text);
    
$i=0;
$test ''.$data[$i]['maxitemcost'].'';

return 
$test;

this returns $test as 25. But then when I go to check this it doesnt seem to work.

eg.
$test = 25 and $data[$i]['cost'] is the cost of something
if ($test > $data[$i]['cost']) {
You have enough money to buy that
}else{
You dont have enough money to buy that

This always seems to return " You dont have enough money to buy that " even if cost is 10...
__________________
Websites Created;
warscope.com
ratepayers.org.nz

Last edited by lothop; 05-25-2009 at 09:58 AM..
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-25-2009, 10:38 AM Re: Returning Variables from a different function
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
you are concatinating spaces either end of the $test value ???

Why are you doing this?
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Old 05-25-2009, 07:23 PM Re: Returning Variables from a different function
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Cheers, that was all it was, those spaces. Dang, I thought I tried everything. Thankyou
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Returning Variables from a different function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.91187 seconds with 12 queries