array value within Rule's PHP action always gives 0 instead of related uid I want to fetch the latest Ubercart order's associated uid and if it is NOT the same as the newest user's ID then my Rule should validate and send an email to a selected address.

In the Rule I created, I've written the following PHP action in order to first check what $uids[0] is giving me. When this works as require, I'll put the same code as a PHP condition, replacing the watchdogs with return FALSE &amp; TRUE.

The problem I'm facing is that $uids[0] always gives 0 instead of the last order's user ID.

$query = db_query("SELECT uid, created FROM {uc_orders} order by created desc");
$uids = array();
while ($records = db_fetch_array($query)) {
    $uids[] = $records['uid'];
}
$latestaccountuid = $account-&gt;uid;
$latestorderuid = $uids[0];

$message = "Latest account id:".$latestaccountuid." .Latest order uid:".$latestorderuid;

if ($latestaccountuid == $latestorderuid) {
watchdog('FALSE', $message);
//return FALSE;
}
else {
watchdog('TRUE', $message);
//return TRUE;
}
I think the problem is with your $account variable. I don't see where it's instanciated in your code. It's probably related to the current logged in user, so you've to find a way to access this information from Rules. Try to use dsm($account); if you're using the devel module and check if the variable is empty.