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

Reply
 
Thread Tools Display Modes
  #71  
Old 08-04-2012, 12:12 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...that doesn't help. Look at the surrounding line for missing quote or unusual characters.
Reply With Quote
  #72  
Old 08-04-2012, 02:10 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It was a missing ! in the following line
Reply With Quote
  #73  
Old 08-04-2012, 09:51 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm about to head to bed after staring at this damn mod for 2 hours trying to find my error.

It imports just fine and the settings work, but when I go to /mics.php?do=unsubscribe all I get is the smiley page. No errors.

So I'm going to attach it here and maybe someone can find the error for me

It's not complete yet, still have to do the user group stuff, the resubscribe stuff, and find a way to store the existing thread subscriptions. The plan for the subscriptions is to create another table to copy the users subscriptions to and the query to take the data from the backup table and repopulate the original.

EDIT: It was a simple typo in the template name So with no errors I can now work on the user group stuff
Reply With Quote
  #74  
Old 08-12-2012, 10:33 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I'm a bit stuck and a little confused (and not about the same thing ).

I basically followed Kevin's "select" and "update" queries to add the other options to be changed. However I'm a little confused why the "select" query selects username and userid when the "update" query doesn't use those variables.

Select query
Code:
$unsubscribe = $db->query_first("SELECT username, userid, email FROM ".TABLE_PREFIX."user WHERE email = '$esc_email' AND options &16");
Update query
Code:
$unsubscribe = $db->query("UPDATE ".TABLE_PREFIX."user SET options = options - 16 WHERE (options & 16) AND email= '" . $db->escape_string($email) . "'");
Now to the part I'm stuck on.... thread subscriptions. When I use my "select" query it triggers this if statment:
Code:
        if (empty($unsubscribe['email']))
        {
            eval(standard_error(fetch_error('advanced_unsubscribe_link_error_unsubscribed', $vbulletin->options['contactuslink'])));
        }
This is the select query
Code:
$unsubscribe = $db->query_first("SELECT * FROM ".TABLE_PREFIX."subscribethread WHERE userid = '$id' AND emailupdate = 1 OR 2 OR 3");
I have other issues with thread subscriptions, but I figure I should find out what's wrong with my select query first

Is it because the subscribethread table doesn't have an email column?
Reply With Quote
  #75  
Old 08-12-2012, 12:45 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't remember why the query included username and userid, I suppose I thought I needed them (or might need them) for one of the other features we talked about. But it also doesn't hurt anything to have them there.

You're right, the subscription table doesn't include email, so there's no reason to check for that field being blank. Also I don't think you're checking correctly for multiple values of emailupdate. I think you want something like:

Code:
$unsubscribe = $db->query_first("SELECT * FROM ".TABLE_PREFIX."subscribethread WHERE userid = '$id' AND emailupdate IN (1, 2, 3)");

I think have "OR 2 OR 3" on the end of the query like that will cause it to return every row.

Oh, that brings up another issue - since you want to return every record of a user's subscriptions, you can't use query_first(), you need to use query_read() and then use a loop to get each record.
Reply With Quote
  #76  
Old 08-12-2012, 11:53 PM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the tips on thread subscription I thought it was the '$id' that was returning every row, I'll use IN and see what happens
Reply With Quote
  #77  
Old 08-19-2012, 08:34 PM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I have confused myself once again The subscribethread table has one column (subscribethreadid) that is auto increment, according to this website https://www.vbulletin.com/docs/html/...ards_sql_query I'm not supposed to include that field in an insert query.

I have tried the following queries which result in different errors.


Code:
        $db->query_write("
            INSERT INTO ".TABLE_PREFIX."unsub_subscribethread
            SELECT userid,
                   threadid,
                   emailupdate,
                   folderid,
                   canview
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");
error

Quote:
Database error in vBulletin 4.1.12:

Invalid SQL:

INSERT INTO unsub_subscribethread
SELECT userid,
threadid,
emailupdate,
folderid,
canview
FROM subscribethread
WHERE userid = ''
AND emailupdate IN (1, 2, 3);

MySQL Error : Column count doesn't match value count at row 1
Error Number : 1136
Request Date : Sunday, August 19th 2012 @ 08:18:50 PM
Error Date : Sunday, August 19th 2012 @ 08:18:50 PM
Script : http://localhost/vb4112/misc.php
Referrer : http://localhost/vb4112/misc.php?do=unsubscribe
IP Address : 127.0.0.1
Username : zombie
Classname : vB_Database
MySQL Version : 5.1.36-community-log
I don't understand how to use VALUES in this case (because the values can't be hard coded IE 5 for userid etc etc), everything I've tried results in syntax errors. So what would I put after VALUES?

Code:
        $db->query("
            INSERT INTO ".TABLE_PREFIX."unsub_subscribethread
            VALUES What goes here?
            SELECT (userid, threadid, emailupdate, folderid, canview)
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");
So I went with the SELECT * to insert everything from subscribethreads.

Code:
        $db->query_write("
            INSERT INTO ".TABLE_PREFIX."unsub_subscribethread
            SELECT *
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");
error

None but it doesn't populate unsub_subscribethread, is it because of the auto increment column in subscribethread?

According to this website http://www.w3schools.com/sql/sql_select_into.asp I should be using SELECT INTO to copy subscribethread to unsub_subscribethread (vs INSERT INTO) at least that's how I understand it so I tried;

Code:
        $db->query_write("
            SELECT userid,
                   threadid,
                   emailupdate,
                   folderid,
                   canview
            INTO ".TABLE_PREFIX."unsub_subscribethread
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");
error

Quote:
Database error in vBulletin 4.1.12:

Invalid SQL:

SELECT userid,
threadid,
emailupdate,
folderid,
canview
INTO unsub_subscribethread
FROM subscribethread
WHERE userid = ''
AND emailupdate IN (1, 2, 3);

MySQL Error : Undeclared variable: unsub_subscribethread
Error Number : 1327
Request Date : Sunday, August 19th 2012 @ 08:28:26 PM
Error Date : Sunday, August 19th 2012 @ 08:28:26 PM
Script : http://localhost/vb4112/misc.php
Referrer : http://localhost/vb4112/misc.php?do=unsubscribe
IP Address : 127.0.0.1
Username : zombie
Classname : vB_Database
MySQL Version : 5.1.36-community-log
Now I can only guess that this is caused by me creating the table unsub_subscreibethread in the "<installcode>" at the start of the plugin (code is below for reference). If I understand what SELECT INTO is supposed to do, it's creating the table "unsub_subscribethread" on the fly? So this wouldn't work because it would try to create the table each time the script is run?

Code:
$db->query_write("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."unsub_subscribethread LIKE ".TABLE_PREFIX."subscribethread");
Reply With Quote
  #78  
Old 08-19-2012, 08:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't tried these, but I think there's two things you can do: when a column is auto increment, you don't want to supply a value but you can put NULL as a placeholder. You can put NULL where you'd put a column name in a select, and that value will always be null. So I think this would work:

Code:
        $db->query_write("
            INSERT INTO ".TABLE_PREFIX."unsub_subscribethread
            SELECT NULL,
                   userid,
                   threadid,
                   emailupdate,
                   folderid,
                   canview
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");

The other way would be to list each column and leave out the id column, like:

Code:
        $db->query_write("
            INSERT INTO ".TABLE_PREFIX."unsub_subscribethread
                (userid, threadid, emailupdate, folderid, canview)
            SELECT userid,
                   threadid,
                   emailupdate,
                   folderid,
                   canview
            FROM ".TABLE_PREFIX."subscribethread
            WHERE userid = '$id'
            AND emailupdate IN (1, 2, 3)");

BTW, for future reference you can see some of this in the mysql manual, for instance here's the page for the INSERT statement: http://dev.mysql.com/doc/refman/5.0/en/insert.html
Reply With Quote
  #79  
Old 08-21-2012, 03:28 AM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well so far nothing has worked as far as populating unsub_subscribethread. However plugging each query into phpmyadmin (removing the table prefix and defining a user) works.

So it's either not pulling the userid properly, or my loop is screwed up (which certainly wouldn't surprise me). I'll have to do some more reading and hopefully find an good loop example instead of the crap that's in the tutorials.
Reply With Quote
  #80  
Old 08-27-2012, 07:44 PM
John Lester John Lester is offline
 
Join Date: Nov 2004
Posts: 543
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A week ago or so I screwed up and deleted my "good" file for the mod and instead saved the "working" copy. Well when I navigate to the page on my local test site for testing I get the following error;

Quote:
Parse error: parse error, expecting `']'' in C:\wamp\www\vb4112\misc.php(89) : eval()'d code on line 85
What on earth is it looking for? I have not found any open brackets anywhere

While I am on this subject ... why are there two ' after the ] ? For that matter why is there a ` before it?

misc.php code from line 80 to 89

Code:
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

($hook = vBulletinHook::fetch_hook('misc_start')) ? eval($hook) : false;

// ############################### start buddylist ###############################
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 11:26 PM.


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.04480 seconds
  • Memory Usage 2,298KB
  • 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
  • (13)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete