vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   whats wrong with this ? (https://vborg.vbsupport.ru/showthread.php?t=169116)

wolfe 01-30-2008 12:41 AM

whats wrong with this ?
 
i am trying to get the favourite mod from the arcade hack to work on another part of my forum so far php correct but theres a problem with the script the image is not changing on click ? and ideas.

PHP Code:

<script type="text/javascript">

var 
lastfav;


// Favorites handling.
function favsprocess()
{
    if (
xml.handler.readyState == && xml.handler.status == 200 && xml.handler.responseText)
    {
        
thisfav document.getElementById('favs_' lastfav);
        if (
xml.handler.responseText==1)
        {
            
thisfav.src 'images/thread/subfav.gif';
            
thisfav.alt 'Remove Favourite';
            
thisfav.title 'Remove Favourite';
        } else if (
xml.handler.responseText==2)
        {
            
thisfav.src 'images/thread/addfav.gif';
            
thisfav.alt 'Add Favourite';
            
thisfav.title 'Add Favourite';
        }
        
    }
}

function 
dofavs(threadid)
{
    
xml = new vB_AJAX_Handler(true);
    
xml.onreadystatechange(favsprocess);
    
    
lastfav threadid;
    
xml.send('tindex.php''do=processfav&threadid=' threadid);
}


</
script


cheesegrits 01-30-2008 03:14 AM

I'm not entirely sure, but I don't think you can change a src like that. I think you have to use Image objects, like this:

Code:

<script type="text/javascript">

var lastfav;

var subfav = new Image();
var addfav = new Image();

subfav.src = 'images/thread/subfav.gif';
addfav.src = 'images/thread/addfav.gif';

// Favorites handling.
function favsprocess()
{
    if (xml.handler.readyState == 4 && xml.handler.status == 200 && xml.handler.responseText)
    {
        thisfav = document.getElementById('favs_' + lastfav);
        if (xml.handler.responseText==1)
        {
            thisfav.src = subfav.src;
            thisfav.alt = 'Remove Favourite';
            thisfav.title = 'Remove Favourite';
        } else if (xml.handler.responseText==2)
        {
            thisfav.src = addfav.src;
            thisfav.alt = 'Add Favourite';
            thisfav.title = 'Add Favourite';
        }
       
    }
}

function dofavs(threadid)
{
    xml = new vB_AJAX_Handler(true);
    xml.onreadystatechange(favsprocess);
   
    lastfav = threadid;
    xml.send('tindex.php', 'do=processfav&threadid=' + threadid);
}


</script>

Like I said, I'm not sure, but give that a go.

-- hugh

wolfe 01-30-2008 10:53 AM

worked a treat m8 thx

PHP Code:

WHERE thread.threadid IN($tindex

its not just seleting the threads with the fav ids ?

the $tindex look like this 1223,3434,5252,5251 etc

cheesegrits 01-30-2008 03:12 PM

Can you post the whole query?

The only thing I can think of without any context is that maybe you are using 'single quotes' rather than "double quotes", so $tindex isn't getting expanded.

-- hugh

wolfe 01-30-2008 08:43 PM

PHP Code:

     $favcache unserialize($vbulletin->userinfo['tfavcache']);
     
// Favorites
     
$tindex implode(',', (array)$favcache);

    
$threadarray $vbulletin->db->query_read("
        SELECT thread.*, icon.title AS icontitle, icon.iconpath AS iconpath, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid

        FROM " 
TABLE_PREFIX "thread AS thread 
        LEFT JOIN " 
TABLE_PREFIX "icon AS icon ON(icon.iconid = thread.iconid)    
        LEFT JOIN  " 
TABLE_PREFIX "user AS user ON (user.username = thread.postusername)
        WHERE thread.threadid IN(
$tindex$pqr
        ORDER BY 
$sqlsort $sortorder $secondarysortsql
        LIMIT " 
. ($limitlower 1) . ", $perpage "); 


cheesegrits 01-30-2008 11:14 PM

Nothing obvious wrong with that.

You might want to try assigning the query to a variable and var_dumping() it before it executes, so you can copy and paste the literal query into somelike like phpMyAdmin or a mysql command line, and see what it actually generates.

-- hugh


All times are GMT. The time now is 03:27 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.01012 seconds
  • Memory Usage 1,744KB
  • 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
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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