PDA

View Full Version : Need Help With Passing Var To Function


paul41598
12-23-2006, 04:06 PM
I can't get this to work for the love of god, need assistance. Basically Im grabbing some data where theres a condition, if meet it sends off a PM.

I think the trouble is passing of variables. Because the PM arrays, etc arnt getting passed into the send_pm() function. I mean, I think they are but it is echoing back the wrong results, errr, wrong format anyways.



$userpointsqry = $vbulletin->db->query_read("
SELECT score_times, ptp_log, userid, username
FROM " . TABLE_PREFIX . "user
WHERE score_times >= " . $vbulletin->options['ptp_groan_amount_level1'] . "
");

$pmto_users = array();

while($pquery = $vbulletin->db->fetch_array($userpointsqry))
{

$pmto_users[] = $pquery['username']; // initiliaze array for PM sending


// if rows are less than 1, PM to that person, if multiple, select ALL receipients

if ($vbulletin->db->num_rows($userpointsqry) <= 1)
{
$pmtousernames = $pquery['username'];
}
else {
$pmtousernames = implode(';', $pmto_users);
}


// Lets update the users points now
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET vbbux = '" . $amt1 . "'
WHERE score_times >= " . $vbulletin->options['score_amount_level1'] . "
");
start_pm(); // SEND THE PM!!

} // end while loop



// Start Private Message Code
function start_pm()
{

echo "$pmtousernames"; //this is just for testing purposes to see what it displays

// THE ABOVE DISPLAYS CMUrickCMUrick;Pepsico
// SUPPOSED TO DISPLAY CMUrick;Pepsico

}




I tried putting like "global $vbulletin, $pquery, $pmto_users, $userpointsqry, $pmtousernames;" right after:
function start_pm()
{

but that didnt help either.