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 04-11-2010, 06:42 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Users must post before voting

How would I go about doing this?

I've tried the below to give me an array but it results in a fatal error.


PHP Code:
$checkpost $vbulletin->db->query_read("
        SELECT username
        FROM " 
TABLE_PREFIX "post
        WHERE threadid = '"
.$threadid."'
    "
); 
Reply With Quote
  #2  
Old 04-11-2010, 06:56 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what your array code look like

you need to fetch through the results
Reply With Quote
  #3  
Old 04-11-2010, 07:38 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've fixed the fatal error issue. But the following isn't working. It should print out the array but it isnt'.

PHP Code:
$threadid $vbulletin->db->query_first("
        SELECT threadid
        FROM " 
TABLE_PREFIX "thread
        WHERE pollid = '"
.$pollida."'
    "
);

$checkpost $vbulletin->db->query_read("
        SELECT username
        FROM " 
TABLE_PREFIX "post
        WHERE threadid = '"
.$threadid."'
    "
);
while (
$posts $db->fetch_array($checkpost))
{
print_r($posts);

Reply With Quote
  #4  
Old 04-11-2010, 04:35 PM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

while($post = $vbulletin->db->fetch_array)
Reply With Quote
  #5  
Old 04-11-2010, 07:49 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That returns mysqli_result Object ( ).
Reply With Quote
  #6  
Old 04-12-2010, 04:03 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i had this problem on one of my plugins and thats how i fixed it
PHP Code:
$threadid $vbulletin->db->query_first("
        SELECT threadid
        FROM " 
TABLE_PREFIX "thread
        WHERE pollid = '"
.$pollida."'
    "
);

$checkpost $vbulletin->db->query_read("
        SELECT username
        FROM " 
TABLE_PREFIX "post
        WHERE threadid = '"
.$threadid."'
    "
);
while (
$posts $vbulletin->db->fetch_array($checkpost))
{
print_r($posts);

try it like that
Reply With Quote
  #7  
Old 04-12-2010, 05:31 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's what returns mysqli_result Object ( ).
Reply With Quote
  #8  
Old 04-12-2010, 05:34 AM
killa seven killa seven is offline
 
Join Date: Aug 2007
Posts: 76
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Pandemikk View Post
That's what returns mysqli_result Object ( ).
weird i didn't know vbulletin has mysqli methods.. could be wrong

its best practice to use $vbulletin-> if your using db->


always fixes most of my problems when i put it in
Reply With Quote
  #9  
Old 04-12-2010, 09:16 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the following code, $threadid is an array with the contents of a single database row.
Code:
$threadid = $vbulletin->db->query_first("
       SELECT threadid
       FROM " . TABLE_PREFIX . "thread
       WHERE pollid = '".$pollida."'
   ");
So to use the threadid in the next query, you will need to use $threadid['threadid']:
Code:
$checkpost = $vbulletin->db->query_read("
       SELECT username
       FROM " . TABLE_PREFIX . "post
       WHERE threadid = ".$threadid['threadid']."
Reply With Quote
  #10  
Old 04-13-2010, 12:42 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahhh^

I should have known that!

Thanks Marco.

----
PHP Code:
$posthreadid $vbulletin->db->query_first("
        SELECT threadid
        FROM " 
TABLE_PREFIX "thread
        WHERE pollid = '"
.$pollida."'
    "
);

$checkpost $vbulletin->db->query_read("
       SELECT username
       FROM " 
TABLE_PREFIX "post
       WHERE threadid = "
.$posthreadid['threadid']."
    "
);

while (
$posts $vbulletin->db->fetch_array($checkpost))
{
if (
$posts['username'] != $vbulletin->userinfo['username'])
{
standard_error(fetch_error('bs_postfirst'));
}         

The array is perfect. But how would I go about checking each result to $vbulletin->userinfo['username'] ?

I thought the above code would work.
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 07:41 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.04870 seconds
  • Memory Usage 2,269KB
  • 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
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)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
  • (1)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