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 08-04-2007, 11:13 PM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What's Wrong With My Code?

Can someone explain what I'm doing wrong?

PHP Code:
$entry$db->query_first("SELECT tags FROM " TABLE_PREFIX "journal_entries WHERE journal_id=1");
        
$entry['tags'] = stripslashes($entry['tags']);            
if (
$entry['tags'])
{
        
$kwords explode(','trim($entry['tags']));
        
$entry['tags'] = '';
        foreach (
$kwords AS $keyword)
        {    
        
$keyword trim($keyword);
        
$entry['tags'] .='<a href="/journal.php?' .$vbulletin->session->vars['sessionurl']. 'do=showjournal&amp;tag='.$keyword.'&amp;j='.$j.'" target="_top">' .$keyword'</a>, ';
            
        }
        
$entry['tags']= substr_replace($entry['tags'],'',-2);
    }
            
   eval(
'print_output("' fetch_template('journal_blogcloud') . '");');
$db->free_result($entry); 
I'm trying to get this to export all the "tags" (separated by a comma) by a journal ID.

What's wrong with my code?
Reply With Quote
  #2  
Old 08-04-2007, 11:49 PM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What error do you get?
Reply With Quote
  #3  
Old 08-04-2007, 11:52 PM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No error, it's just not exporting anything in the template for "$entry[tags]"

Do I need a while statement somewhere?
Reply With Quote
  #4  
Old 08-05-2007, 12:10 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I edited your code for testing purposes, and it seems to be working for me this way. So if $entry['tags'] really holds the expected content, it should work.

PHP Code:
<?php

// $entry = $db->query_first("SELECT tags FROM " . TABLE_PREFIX . "journal_entries WHERE journal_id=1");
$entry['tags'] = 'test, one, two, three four, five';

if (
$entry['tags'])
{
    
$kwords explode(','trim(stripslashes($entry['tags'])));
    
$entry['tags'] = array();

    foreach (
$kwords AS $keyword)
    {    
        
$keyword trim($keyword);
        
$entry['tags'][] = '<a href="/journal.php?' $vbulletin->session->vars['sessionurl'] . 'do=showjournal&amp;tag='.$keyword.'&amp;j='.$j.'" target="_top">' .$keyword'</a>';
    }

    
$entry['tags'] = implode(', '$entry['tags']);
    echo 
$entry['tags'];
}

// eval('print_output("' . fetch_template('journal_blogcloud') . '");');
// $db->free_result($entry);
Reply With Quote
  #5  
Old 08-05-2007, 12:17 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$entry['tags'] has some "null" data ... would that cause a problem?
PHP Code:
$entry $db->query_first("SELECT tags FROM " TABLE_PREFIX "journal_entries WHERE journal_id =" $vbulletin->GPC['j']." AND tags IS NOT NULL"); 
EDIT: only pulls one entry from the correct row ... not all of them.

should i be doing a "query" instead -- and then grabbing the data out of the array a different way?
Reply With Quote
  #6  
Old 08-05-2007, 12:20 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your script expects $entry['tags'] to hold a string, with comma separated values. Can you post an example of what $entry['tags'] holds?
Reply With Quote
  #7  
Old 08-05-2007, 12:22 AM
noonespecial noonespecial is offline
 
Join Date: Nov 2002
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some examples:

random, staff, inside

random

drew

NULL

Quote:
tags varchar(255) latin1_swedish_ci Yes NULL
From PHPMyadmin, if this helps.

PHP Code:
$entrys $db->query_read("SELECT * , tags IS NULL AS isnull FROM " TABLE_PREFIX "journal_entries WHERE journal_id =" $vbulletin->GPC['j']." ORDER BY isnull ASC, tags ASC");    
        
while (
$entry $db->fetch_array($entrys))
{
        
if (
$entry['tags'])
    {
        
$kwords explode(','trim($entry['tags']));
        
$entry['tags'] = '';
        foreach (
$kwords AS $keyword)
        {    
        
$keyword trim($keyword);
        
$entry['tags'] .='<a href="/journal.php?' .$vbulletin->session->vars['sessionurl']. 'do=showjournal&amp;tag='.$keyword.'&amp;j='.$j.'">' .$keyword'</a>, ';
            
        }
        
$entry['tags']= substr_replace($entry['tags'],'',-2);
    }

Also doesn't work.

Edit:

Do I need to somehow add "commas" to the end of the other values?

I am so lost..

Someone, please help.
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 01:16 PM.


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.03815 seconds
  • Memory Usage 2,250KB
  • Queries Executed 13 (?)
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
  • (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
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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