Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts

    Function not returning value?

    I have the following function...
    PHP Code:
        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:
    PHP Code:
            $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?
    Last edited by dniwebdesign; 11-12-2010 at 06:45 PM. Reason: Resolved
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Give this a shot:
    PHP Code:
        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
            } 
        } 

  • #3
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts
    I figured it was something simple... but at 2:30 in the morning I'm bound to miss the simple things. Thanks man!
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •