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 07-21-2005, 06:08 AM
Benumbed Benumbed is offline
 
Join Date: Oct 2004
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default WHERE Clause

If I do...
PHP Code:
    $loadedmodulename $loadedmodule[module];





    
$settings $DB_site->query("
        SELECT setting.*, settinggroup.*
        FROM " 
TABLE_PREFIX "dwip_module_settinggroup AS settinggroup
        LEFT JOIN " 
TABLE_PREFIX "dwip_module_setting AS setting USING(grouptitle)
        WHERE settinggroup.module = 
$loadedmodulename
    "
); 
I get

PHP Code:
Database error in vBulletin 3.0.7:

Invalid SQL
        
SELECT setting.*, settinggroup.*
        
FROM dwip_module_settinggroup AS settinggroup
        LEFT JOIN dwip_module_setting 
AS setting USING(grouptitle)
        
WHERE settinggroup.module sitenav

    
mysql error
Unknown column 'sitenav' in 'where clause' 
but if I manually put

PHP Code:
WHERE settinggroup.module 'sitenav' 
it works fine.

Its as though its not passing the variable right or I am calling it wrong within the WHERE. I have tried different ways but cant seem to get it.
Reply With Quote
  #2  
Old 07-21-2005, 06:12 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try
PHP Code:
WHERE settinggroup.module='$loadedmodulename' 
Reply With Quote
  #3  
Old 07-21-2005, 06:25 AM
Benumbed Benumbed is offline
 
Join Date: Oct 2004
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I had tried that before...

Warning: Invalid argument supplied for foreach() in /admincp/dwip_modules.php on line 834


This is that line
PHP Code:

            
foreach ($grouptitlecache AS $curgroup => $group)
            {
                
print_dwipsetting_group($curgroup$advanced);
                
print_description_row("<input type=\"submit\" class=\"button\" value=\" $vbphrase[save] \" tabindex=\"1\" title=\"" $vbphrase['save_settings'] . "\" />"02'tfoot" style="padding:1px" align="right');
                
print_table_break(' ');
            } 
What is weird is that if I dont do '$loadedmodulename' and do 'sitenav' (which is one of the variables), it works fine. I cant understand why if I manually do it in script, it works but as a variable, it doesnt. I cant just do 'sitenav" either as there is like 20 different variables on what I am trying to seperate.
Reply With Quote
  #4  
Old 07-21-2005, 06:45 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
WHERE settinggroup.module='" . addslashes($loadedmodulename) . "' 
Try the above line instead, sounds to me like you have a modulename with a quote in it or another special character.
Reply With Quote
  #5  
Old 07-21-2005, 06:49 AM
Benumbed Benumbed is offline
 
Join Date: Oct 2004
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

same thing =\

I really dont understand why it doesnt work.

Explain (its in debug mode trying to fix this) of it with $ variable
PHP Code:
Query:

        
SELECT setting.*, settinggroup.*
        
FROM dwip_module_settinggroup AS settinggroup
        LEFT JOIN dwip_module_setting 
AS setting USING(grouptitle)
        
WHERE settinggroup.module='' 
    
Time before0.090831995010376
Time after
0.091269016265869
Time taken
0.00043702125549316

table type possible_keys key key_len ref rows Extra 
settinggroup  ALL          3  Using where  
setting  ALL          3 
Explain if I just set it a constant (sitenav)

PHP Code:
Query:

        
SELECT setting.*, settinggroup.*
        
FROM dwip_module_settinggroup AS settinggroup
        LEFT JOIN dwip_module_setting 
AS setting USING(grouptitle)
        
WHERE settinggroup.module='sitenav' 
    
Time before0.12685608863831
Time after
0.12722706794739
Time taken
0.00037097930908203

table type possible_keys key key_len ref rows Extra 
settinggroup  ALL          3  Using where  
setting  ALL          3 
Reply With Quote
  #6  
Old 07-21-2005, 07:02 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Query:

SELECT setting.*, settinggroup.*
FROM dwip_module_settinggroup AS settinggroup
LEFT JOIN dwip_module_setting AS setting USING(grouptitle)
WHERE settinggroup.module=''
By the looks of it, the $loadedmodulename variable is empty.
Reply With Quote
  #7  
Old 07-21-2005, 07:08 AM
Benumbed Benumbed is offline
 
Join Date: Oct 2004
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Its not, that was the explain after I hit "Edit Setting"

Before Explain is this...

PHP Code:

Query
:

        
SELECT setting.*, settinggroup.*
        
FROM dwip_module_settinggroup AS settinggroup
        LEFT JOIN dwip_module_setting 
AS setting USING(grouptitle)
        
WHERE settinggroup.module='sitenav' 
    
Time before0.31128311157227
Time after
0.31180191040039
Time taken
0.000518798828125

table type possible_keys key key_len ref rows Extra 
settinggroup  ALL          3  Using where  
setting  ALL          3 
What this basically is, is the vBulletin Options call (to edit your settings) modified to do some other options of a portal like thing I am trying to make. Somewhere between me seeing the options and then clicking on Show all setting, its like its losing the variable if I have it a variable and not a constant.

After typing my last response, I gotta hint and sure enough.. I forgot my hiddencode tags...thanks =P
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 09:04 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.04763 seconds
  • Memory Usage 2,246KB
  • Queries Executed 11 (?)
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
  • (9)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_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