Simplest Mod

Started by RustyBarnacle, February 03, 2011, 12:09:35 PM

Previous topic - Next topic

Arantor

The sportspool array... is it global? Passed in to the function?

RustyBarnacle

Yes, thats why the template echos a different number, the way it should, each time the corresponding template function is called.

Arantor

Show me the whole function.

RustyBarnacle

#83
[code[
function confirm()
{
global $txt, $context, $scripturl, $db_prefix, $user_info, $ID_MEMBER, $sportspool, $smcFunc;

findchoices();
findeve();
$eve = $sportspool['eve'];

if ($sportspool['numbchoices'] == count($_POST['ChosenOnes']))
{
// See if there is a wager level change
findwager();
$wagerlevel = $sportspool['wagerlevel'];

// Create SQL statement for choices about to be made
$ID_MEMBER = $context['user']['id'];
$transX = mt_rand(1, 99999990);
$t =  array();
$te = $_POST['ChosenOnes'];
foreach ($te AS $tes)
$t[] = array($context['user']['id'], $tes, $wagerlevel, $transX);

$smcFunc['db_insert']('insert', '{db_prefix}sportspool_choices',
array(
'ID_MEMBER' => 'int', 'ID_Athlete' => 'int', 'WagerLevel' => 'int', 'ID_TransX' => 'int',
),
$t
);

$sportspool['transX'] = $transX;

$request = $smcFunc['db_query']('', "
SELECT
Name
FROM
{db_prefix}sportspool_athlete
WHERE
{db_prefix}sportspool_athlete.ID_Athlete IN(".implode(', ', $te).")
");

$sportspool['conpicks'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$sportspool['conpicks'][] = array(
'cname' => $row['Name'],
);
}
$smcFunc['db_free_result']($request);

// Load the Paypal address
$request = $smcFunc['db_query']('', "
SELECT
PaypalEmail
FROM
{db_prefix}sportspool_events
WHERE
{int:eve_ID} = {db_prefix}sportspool_events.EventID",
array(
'eve_ID' => $eve
)
);

$row = $smcFunc['db_fetch_assoc']($request);
$sportspool['PaypalEmail'] = $row['PaypalEmail'];
$smcFunc['db_free_result']($request);

$context['sub_template']  = 'confirm';
}
else
$context['sub_template']  = 'wrongchoices';

}

RustyBarnacle

Sorry that took so long to get the whole thing to work.  I'm on a flaky cell connection and Rogers sucks at sending data so I have troubles when making long posts. 

Arantor

I see no obvious reason why that wouldn't work as intended... :/

RustyBarnacle

Me either, but thanks for looking.

RustyBarnacle

I found a work around.  I took a 9 out of the max size.  It's a medium int size 8 and the number that it always stored was randomish and 8 numbers in size, but always the same.

By notching it down to only 7 numbers in size, it saves the right random number to the db every time now.

Arantor

Interesting... Sounds like some kind of overflow... Mediumint caps at 16777215 if it's unsigned...

RustyBarnacle

Ahhh, that was the number it was saving.  I didn't know there was a cap if you specified a size.

Arantor

There's a cap regardless, it's a MySQL constraint, and it's based on the field type. The numeric size is merely to indicate to MySQL the size of number you're expecting so if you query it over a command line, it knows how many text columns to reserve.

RustyBarnacle


Advertisement: