PDA

View Full Version : Stumped on passing a string - SOLVED


Antivirus
11-16-2006, 08:27 PM
I've been able to pass form variables between different scripts within admincp with no problem, however I am trying to use different branches within the same script (as I should), but this has really got me stumped and I can't see what i'm doing wrong here. If anyone can help, i'll do a little dance or something...

Data is submitted through a form with multiple events on each line and each line has a checkbox:

<input type=\"checkbox\" name=\"idsforaction[]\" value=\"" . $event['eventid'] . "\">


Here's how I am sending the eventids to the remove branch...

$strIDs = implode(",", $_POST['idsforaction']);
header("Location:scst_eventsmanager.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&amp;eventids=".$strIDs);


Now i have echoed the location string above before calling the header function and it shows just as it should, for instance:
Location:scst_eventsmanager.php?do=remove&eventids=6,3,4,5

But when the remove branch is executed, the eventids never seem to pass. Here's my remove branch:

if ($_REQUEST['do'] == 'remove')
{
$vbulletin->input->clean->gpc('g', 'eventids', TYPE_STR);

$sql = $db->query_read("
SELECT eventid, eventdate AS date, eventdescription AS title
FROM " . TABLE_PREFIX . "scst_event
WHERE eventid IN '" . $vbulletin->GPC['eventids'] . "'
");

print_form_header('scst_eventsmanager', 'kill');
construct_hidden_code('idforaction', $vbulletin->GPC['eventids']);
print_table_header($vbphrase['confirm_deletion']);
while ($delevent = $db->fetch_array($sql))
{
$deleventdate = vbdate($vbulletin->options['dateformat'], $delevent['date'], 1);
print_description_row("
<blockquote><br />
" . construct_phrase($vbphrase["are_you_sure_want_to_delete_event_x"], $deleventdate, $delevent['title'], $delevent['eventid']) . "
<br /></blockquote>\n\t");
}
print_submit_row($vbphrase['yes'], '', 2, $vbphrase['no']);
}


Now for some reason, it doesn't seem to pass the eventids to the remove branch. If it did, I woudl see the info for each of them in the confirmation box's description rows which are printed for each event I am about to delete, correct?

If I ever get past the remove branch, my kill branch looks like this:

if ($_POST['do'] == 'kill')
{
// to delete event
$db->query_write("DELETE FROM " . TABLE_PREFIX . "scst_event
WHERE eventid = " . $vbulletin->GPC['idforaction']
);
// to delete event's associated staffnotes
$db->query_write("DELETE FROM " . TABLE_PREFIX . "scst_staffnotes
WHERE eventid = " . $vbulletin->GPC['idforaction']
);

define('CP_REDIRECT', 'scst_eventsmanager.php?do=modify');
print_stop_message('event_has_been_deleted');
}


Thanks!

Adrian Schneider
11-16-2006, 09:09 PM
I'm pretty sure it's working but your query is incorrect... I think it's taking the whole list and interpreting it as a string, rather than a list. Instead of this WHERE eventid IN '" . $vbulletin->GPC['eventids'] . "' use thisWHERE eventid IN (" . $vbulletin->GPC['eventids'] . ")You may also want to do some more cleaning on that string, but it's not a big deal because it's in the AdminCP.

Antivirus
11-16-2006, 09:17 PM
Sir you rock, u always answer my questions so quickly :) . I actually just got it to work, that's correct, i needed the eventids surrounded by () after IN in the sql... also other thing i noticed was the following (which i am kickin myself in the butt for):


header("Location:scst_eventsmanager.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&amp;eventids=".$strIDs);


should have been:

header("Location:scst_eventsmanager.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&eventids=".$strIDs);


it didn't like using &amp; when sending the eventids to my remove branch (doh!)
Thanks for yourhelp!

Adrian Schneider
11-16-2006, 10:14 PM
No problem. :)