vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   WHERE Clause (https://vborg.vbsupport.ru/showthread.php?t=92594)

Benumbed 07-21-2005 06:08 AM

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.

Adrian Schneider 07-21-2005 06:12 AM

try
PHP Code:

WHERE settinggroup.module='$loadedmodulename' 


Benumbed 07-21-2005 06:25 AM

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.

Marco van Herwaarden 07-21-2005 06:45 AM

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.

Benumbed 07-21-2005 06:49 AM

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 


Marco van Herwaarden 07-21-2005 07:02 AM

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.

Benumbed 07-21-2005 07:08 AM

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


All times are GMT. The time now is 02:25 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.01817 seconds
  • Memory Usage 1,756KB
  • 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
  • (9)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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