vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Stumped on passing a string - SOLVED (https://vborg.vbsupport.ru/showthread.php?t=131746)

Antivirus 11-16-2006 08:27 PM

Stumped on passing a string - SOLVED
 
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:
Code:

<input type=\"checkbox\" name=\"idsforaction[]\" value=\"" . $event['eventid'] . "\">
Here's how I am sending the eventids to the remove branch...
PHP Code:

$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:
PHP Code:

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:
PHP Code:

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
Code:

WHERE eventid IN '" . $vbulletin->GPC['eventids'] . "'
use this
Code:

WHERE 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):

Code:

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

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. :)


All times are GMT. The time now is 02:34 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00998 seconds
  • Memory Usage 1,743KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete