Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-16-2006, 08:27 PM
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Location: Black Lagoon
Posts: 1,090
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!
Reply With Quote
  #2  
Old 11-16-2006, 09:09 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 11-16-2006, 09:17 PM
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
Location: Black Lagoon
Posts: 1,090
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #4  
Old 11-16-2006, 10:14 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03540 seconds
  • Memory Usage 2,219KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete