...

View Full Version : Resolved Function not returning value?



dniwebdesign
11-12-2010, 08:38 AM
I have the following function...

function getUniqueId($time) {
global $db;
$getClientNumber = $db->select("SELECT id FROM `thunder_auction_items` WHERE `item_id`='".$time."'");
if(mysql_num_rows($getClientNumber)>0) {
$time = time();
getUniqueId($time);
}
else {
//echo $time;
return $time;
}
}

which is called by:

$item_id = getUniqueId($_POST["item_id"]);
echo ">".$item_id."<";
However, when I echo the $item_id, it returns nothing. When I echo the $time in the function (which is now commented out), it returns the timestamp. Why is it not echoing anywhere else?

kbluhm
11-12-2010, 10:27 AM
Give this a shot:


function getUniqueId($time) {
global $db;
$getClientNumber = $db->select("SELECT id FROM `thunder_auction_items` WHERE `item_id`='".$time."'");
if(mysql_num_rows($getClientNumber)>0) {
$time = time();
// added `return` here
return getUniqueId($time);
}
else {
//echo $time;
return $time;
}
}

dniwebdesign
11-12-2010, 05:44 PM
I figured it was something simple... but at 2:30 in the morning I'm bound to miss the simple things. Thanks man!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum