Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Seems like this would be pretty simple, however, I'm running into an issue:

Here's the code:

function getValidCustomers() {
    global $db;
    $getCustomers = $db->GetAll("SELECT * from customers where CustomerActive='1' AND protected IS NULL or protected=0;");
    foreach($getCustomers as $customer) {
        echo $customer['CustomerID']."\n";
    }
}

function updateValidCustomers() {
    $customers = getValidCustomers();
    for ($i = 0; $i < sizeof($customers); $i++) {
        echo "DEBUG: $customers[$i]\n";
    }
}

updateValidCustomers();

Basically, the output right now is a list of the CustomerIDs (from updateValidCustomers()). I just want updateValidCustomers() to get the data from getValidCustomers() and then loop through it, so that I can run another query on it that will actually manipulate the database.

Any ideas?

share|improve this question

3 Answers 3

getValidCustomers doesn't return anything, maybe you mean this:

function getValidCustomers() {
    global $db;
    $getCustomers = $db->GetAll("SELECT * from customers where CustomerActive='1' AND protected IS NULL or protected=0;");
    foreach($getCustomers as $customer) {
        echo $customer['CustomerID']."\n";
    }
    return $getCustomers;
}
share|improve this answer
    
sighs - so, so close. You're right (along with everyone else). I originally added return $customer['CustomerID']; and replaced echo $customer['CustomerID']."\n";, but then read that it would basically exit after that matched and that obviously did not resolve my issue. Thanks for the tip guys! –  drewrockshard Jul 31 '11 at 23:56

getValidCustomers() doesn't return anything - it just echoes

Add return $getCustomers to the end of getValidCustomers()

share|improve this answer

Add return $getCustomers; to getValidCustomers() :D

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.