vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Over my head?? (https://vborg.vbsupport.ru/showthread.php?t=43239)

jsell 09-06-2002 02:33 PM

Over my head??
 
Hey everyone first of all i would like ot thank you in advance for the help but here it goes

i am trying to hack my own "admin Recommended" type of hack where I replace the post icon's with a yes or a no icon at my choosing. I want it to show up in the forumdisplay when i choose if i want to reccomend the thread or not. I have everything working except it doesn;t diplay the icon's correctly. obviously there is soemthing wrong with my code. I am pretty new to php and to Vbulletin so please go easy one me.

PHP Code:

// reco hack

unset($recodata);
unset(
$reco);

   
    
    
$recodata=$DB_site->query("SELECT reco from recodata data WHERE threadid='$threadid'");
                   
      if ((
$recodata[recomend]==1)) {
        eval(
"\$reco= \"".gettemplate("reco_yes")."\";");

      } else {
    
        eval(
"\$reco= \"".gettemplate("reco_no")."\";");
      }
    }
  


//end add reco hack 

above is the code i am using in forumdisplay.php

what happens is that is displays only the "reco_no" template

it's like it's either not getting the info from the query or it's using the same info for every thread (i think)

can some one please help

again thanks

Jsell

Velocd 09-07-2002 03:42 AM

Try this jsell:

PHP Code:

// reco hack

    
$recodata=$DB_site->query("SELECT reco FROM recodata WHERE threadid='$threadid'");
                   
      if (
$recodata[reco]==1) {
        eval(
"\$reco= \"".gettemplate("reco_yes")."\";");

      } else {
    
        eval(
"\$reco= \"".gettemplate("reco_no")."\";");
      }  

//end add reco hack 

Youre problem was that you were not getting the values of the query into an array. Whenever you create a array from a query, you must put it in $array[element] form. "element" is usually the name of the column selected in the array. You had a number of small syntax errors in the code.

Also, because this is getting values of many threads, you need to put the code in a while loop, and fetch or extract the array. This while loop has already been made in forumdisplay.php ofcourse.

So in forumdisplay.php, find:
PHP Code:

while ($thread=$DB_site->fetch_array($threads)) { // and $counter++<$perpage) { 

And below it place your code.

Try the above code, I hope it works since I'm not all that sure what you are doing. ;)

jsell 09-07-2002 02:49 PM

Thanks for your help Velocd but there is still a problem:

let me try a more detailed explination and tell you some more test's I have run

What i have done is I added a input field in "showthread" where I can select yes/No for if I recomend a thread to a user to read. For now I am going to replace the message icon with a yes/no icon in the forum display (later I will add a new box in the table for it so I have both icon's) evrythign is wokring except the forum display in thee database if I choose "yes" it enters a value of 1 if i choose "no" i enters a value of 2 etc.

what happens when i enter the code in "forumdisplay.php" your's or mine, is that every thread show's the same icon the icon inside the "reco_no" template.

So to try to test this in the forumdisplaybit template i put the variable $recodata[reco] and it comes up as a blank for every thread even though the database has value's for all of them

My conclusion:

that for some reason the Query is not getting the info form the database (double and triplechecked the table names etc. ) but I can't figure out why it's doing that maybe the
PHP Code:

WHERE threadid='$threadid' 

part is incorrect but i can't find diferent variable to use

jsell

jsell 09-08-2002 11:07 PM

Thanks for the help I found a workaround for this that does what i need

jsell


All times are GMT. The time now is 09:33 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.01404 seconds
  • Memory Usage 1,727KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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