Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 02-03-2009, 10:37 AM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SOLVED. - formulating a if sentence

NO ERRORS ANYMORE READ LAST AREA :P

############################# original post ###############

hmm getting a parse error in this snippit


Code:
 $vbulletin->input->clean_gpc('r', 'invitation', TYPE_NOHTML);
 
    if ($vbulletin->GPC['invitation']){$invitegroupid = $db->query_first_slave("SELECT NewusergroupID FROM " . TABLE_PREFIX . "vbinvitationcode WHERE invitation = " .  $db->escape_string($vbulletin->GPC['InvitationCODE'])}
    { 
            $userdata->set('usergroupid', $invitedgroupid);  
        }
    else
    {
           $userdata->set('usergroupid', $newusergroupid);
    }
Things i suspect, is that
{} dont fit in the if (){} ?

and not really sure that else can be used here, maybe ?
Reply With Quote
  #2  
Old 02-03-2009, 10:52 AM
bananalive bananalive is offline
 
Join Date: Oct 2007
Location: UK
Posts: 2,802
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You've got

if () {}
{
}
else
{
}

when it should be

if (){
}
else
{
}
Reply With Quote
  #3  
Old 02-03-2009, 11:00 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Something like:
PHP Code:
$vbulletin->input->clean_gpc('r''invitation'TYPE_NOHTML);
 
if (
$vbulletin->GPC['invitation'])

  
$invitegroupid $db->query_first_slave("SELECT NewusergroupID FROM " TABLE_PREFIX "vbinvitationcode WHERE invitation = '" .  $db->escape_string($vbulletin->GPC['InvitationCODE'] . "'");
  
$userdata->set('usergroupid'$invitedgroupid);  
}
else
{
  
$userdata->set('usergroupid'$newusergroupid);

But just guessing. If you need more assistence, please also post the error message.
Reply With Quote
  #4  
Old 02-03-2009, 11:18 AM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

all it says is parse error, ewen with "show http errors" enabled in ie.
Code:
Parse error: parse error in D:\xampp\htdocs\forums\invitationcode.php on line 364
that line is the excakt like where this if takes place
the file is a copy of register and in the template on submit it submits to
invitationcode.php instead of register.php

a db view attached
Attachment 93985
Reply With Quote
  #5  
Old 02-03-2009, 03:31 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

okay some guy told me i cannot use the else statment there,
when i look around the document i see it buildt excaktly like that.

but if i exclude the else statement,
how can i make sure all that is not "true" here are changed to $newusergroupid
?
Reply With Quote
  #6  
Old 02-03-2009, 05:01 PM
Ted S Ted S is offline
 
Join Date: Dec 2003
Location: SoCal
Posts: 3,954
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The else statement is fine. Just follow the code Marco van Herwaarden posted and you'll be in good shape.
Reply With Quote
  #7  
Old 02-03-2009, 05:21 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

still getting error
Parse error: parse error in D:\xampp\htdocs\forums\invitationcode.php on line 363

Gonna try it on a live server, if the code is correct maybe its the server
using php 5.2.8 / mysql 5.1.3 and latest apache release.

but it might be missing a module just running of the install, no special modifications made.

OMG..

now im gonna take a brake, now i just learned it DOSENT execute install query when installing
Code:
$db->hide_errors();
		$vbulletin->db->query_write(" 
			CREATE TABLE IF NOT EXISTS `". TABLE_PREFIX ."vbinvitationcode` (
		    `codedbID` INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
		    `InvitationCODE` VARCHAR(100) NOT NULL,
			`NewusergroupID` VARCHAR(100) NOT NULL,
	    ");
		$db->show_errors();
i have also made a drop for the uninstall, but that proberly wont work either.

where does it instruct me, on how to execute a query dureing install,
cant find it in the manual, so simply put it in the install code box.
refering to : http://www.vbulletin.com/docs/html/creating_a_product

off to a brake before i blow up.

[COLOR=""]--------------- Added [DATE]1233706418[/DATE] at [TIME]1233706418[/TIME] ---------------------------------------------[/COLOR]
#########################################EDIT UPDATE BELOW#########################
okay a little update here..

current if statement :
Code:
$vbulletin->input->clean_gpc('r', 'invitation', TYPE_NOHTML);

if ($vbulletin->GPC['invitation'])
{ 
$invitegroupid = $db->query_first_slave("SELECT NewusergroupID FROM " . TABLE_PREFIX . "vbinvitationcode WHERE '" .  $db->escape_string($vbulletin->GPC['invitation'] . "' = InvitaionCODE");
  $userdata->set('usergroupid', $invitedgroupid);  
}
else
{
  $userdata->set('usergroupid', $newusergroupid);
}
how can if ($vbulletin->GPC['invitation']) <-- do anything
shoundt there be a "if ($vbulletin->GPC['invitation'] = content )

cause if i enter "lol1" as invitation code on registration, then the it would say

if (lol1)
{}
else
{}

dosent it just skib the entire if ? since if will never be true, the SQL query just gets the data
but only if "if" is true.

reference of this : http://www.w3schools.com/php/php_if_else.asp
Im thinking maybe run the query :
Code:
$sql = select * InvitationCODE from vbinvitation
if $sql <>
{
set usergroup standard
}
else
{
$newgroupid = select newusergroupID from vbinvitation where $sql = invitation
set usergroupid newgruopid
}
i know its missing alot but its a draft



************************************************** ****SOLVED***************************************

Its not working, but it dosent promt with erros anymore :P

Code:
// 
if ($vbulletin->GPC['invitation'])
{ 
$invitegroupid = $db->query_read_slave("
        SELECT NewusergroupID
		FROM " . TABLE_PREFIX . "vbinvitationcode 
		WHERE InvitationCODE = '" . $db->escape_string($vbulletin->GPC['invitation']) . "'"
	);
  $userdata->set('usergroupid', $invitedgroupid);  
}
else
{
  $userdata->set('usergroupid', $newusergroupid);
}
Reply With Quote
  #8  
Old 02-04-2009, 05:09 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$invitegroupid, as it stands right now, will return an array. And will not work as you want it to. You want to use $invitegroupid['NewusergroupID'].
Quote:
Originally Posted by Vaupell View Post
how can if ($vbulletin->GPC['invitation']) <-- do anything
shoundt there be a "if ($vbulletin->GPC['invitation'] = content )
The first will check if a value is true. True being one that is not null, not an empty array or string, or the integer 0 (a string that is "0" is not true). The second will actually assign the constant "content" (you were probably meaning to use the string, not the constant) to the variable. You were looking for the equivalence operator "==". This checks if the two values are the same (note that it will not check type).
Reply With Quote
  #9  
Old 02-04-2009, 07:21 AM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
$invitegroupid, as it stands right now, will return an array. And will not work as you want it to. You want to use $invitegroupid['NewusergroupID'].

The first will check if a value is true. True being one that is not null, not an empty array or string, or the integer 0 (a string that is "0" is not true). The second will actually assign the constant "content" (you were probably meaning to use the string, not the constant) to the variable. You were looking for the equivalence operator "==". This checks if the two values are the same (note that it will not check type).
yeah that did the trick, now i went from a specifik line error to a db error
possebly something wrong with the SELECT
so i checked it in Navicat entered the SELECT and it gave me an error.

DB looks like :
Attachment 94094

But the Query errrors 1054 :
Attachment 94095

usercode is the userimput, gonna try to exchange places between InvitationCODE(colum) and imput, so it says imput = colum,,
currently i have Colum = imput.. ill ofcourse report back


EDIT : lol well yeah adding '' helps.. result to the original line :
Attachment 94096

just wondering why it dosent check out in vb then..

EDIT 2 :
okay now the code runs through error less..
but aparently dosent check / modify usergroup id.. lol


?????????????????????????????????????????????????? ?????????????????? EDIT 3 :
FULL UPDATE CURRENT CODE running, not working, but no errors either :
Invitationcode.php (modifyed copy of register.php)
around line 212-230 added type
Code:
		'invitation'          => TYPE_STR,
line 362 ish right after coppa selection
Code:
$vbulletin->input->clean_gpc('r', 'invitation', TYPE_NOHTML);

if ($vbulletin->GPC['invitation'])
		 { 
		 	$invitegroupid = $db->query_first_slave("
        	SELECT NewusergroupID
			FROM " . TABLE_PREFIX . "vbinvitationcode 
			WHERE InvitationCODE = '" . $vbulletin->GPC[COOKIE_PREFIX . 'invitation'] . "'");
	
	        $userdata->set('usergroupid', $invitegroupid['NewusergroupID']);  
	     }

if (empty($user['usergroupid']))
       {
       $userdata->set('usergroupid', $newusergroupid);
       }
This runs through but does not change the usergroup ID.

however if i replace the if statement with the original code it DOES change
the usergroup.. but no DB selection.
Code:
 if ($vbulletin->GPC['invitation'] == 'awsome')
	   { 
            $userdata->set('usergroupid', '5');  
        }
	   else
	   {
          	$userdata->set('usergroupid', $newusergroupid);
	   }


################################################## ################################################## #################################### EDIT 4 ################################

Okay moved it all into the existing code for makering usergroups
and it runs smooth, but it still dosent place users in the group
only does "standard behavior" going back to the idea IF dont work as intended

Current usergroupID placement :
PHP Code:
    // assign user to usergroup 3 if email needs verification
$vbulletin->input->clean_gpc('r''invitation'TYPE_NOHTML);


    if (
$vbulletin->options['verifyemail'])
    {
        
$newusergroupid 3;
    }
    else  if (
$vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser'])
    {
        
$newusergroupid 4;
    }
    else if (
$vbulletin->GPC['invitation'])
    {
    
$invitegroupid $db->query_first_slave("
            SELECT NewusergroupID
            FROM " 
TABLE_PREFIX "vbinvitationcode 
            WHERE InvitationCODE = '" 
$vbulletin->GPC[COOKIE_PREFIX 'invitation'] . "'");
    
            
$userdata->set('usergroupid'$invitegroupid['NewusergroupID']);
    }
    else
    {
         
$newusergroupid 2;
    } 
But again if i does this it works, but no db :
PHP Code:
 if ($vbulletin->GPC['invitation'] == 'awsome')
       { 
            
$userdata->set('usergroupid''5');  
        } 
help

Changeing DB table name from NewusergroupID to NUGUID im suspecting interference
between the "other" $newusergroupid used in the same page.
Reply With Quote
  #10  
Old 02-04-2009, 04:03 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

YES EFFING YES,,

it works.. yay.
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:49 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.05623 seconds
  • Memory Usage 2,299KB
  • Queries Executed 12 (?)
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_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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