Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 04-19-2004, 02:08 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default changed order by, now this

ok i changed ORDER BY from DESC to ASC and now nothing shows up! why is it doing that! damn u php!!!!
Reply With Quote
  #2  
Old 04-19-2004, 02:10 AM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's the exact code you're using?
Reply With Quote
  #3  
Old 04-19-2004, 02:20 AM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by assassingod
What's the exact code you're using?
This is now the fourth time that we have had to ask the question. If you expect answers, YOU MUST ALWAYS POST THE CODE IN QUESTION AS WELL AS ANY ERRORS YOU GET.
Reply With Quote
  #4  
Old 04-19-2004, 02:27 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok chill, i get no error messages just nothing shows

PHP Code:
        $fentries$DB_site->query("SELECT entry_id,entrytitle,entrytext,entrydate,entry_totalvotes,entry_totalrating,private,whocanview FROM ".TABLE_PREFIX."journal_entries WHERE journal_id='".$_REQUEST['j']."' AND entry_active='1' ORDER BY entrydate ASC");
                
$check$DB_site->num_rows($fentries);
                if(
$check=="0")
                {
                    
$entrybits$vbphrase['journalnoentries'];
                }
                else
                {
                    while(
$entry$DB_site->fetch_array($fentries))
                    {
                        
$count$DB_site->query_first("SELECT COUNT(*) AS comments FROM ".TABLE_PREFIX."journal_comments WHERE journal_id='".$_REQUEST['j']."' AND entry_id='".$entry['entry_id']."'");
                        
$entry['date']= vbdate($vboptions['dateformat'], $entry['entrydate'], 1);
                        
$entry['time']= vbdate($vboptions['timeformat'], $entry['entrydate']);
                        if(empty(
$entry['entry_totalrating']) OR empty($entry['entry_totalvotes']))
                        {
                            
$rating"0";
                        }
                        else
                        {
                            
$calcrating$entry['entry_totalrating']/$entry['entry_totalvotes'];
                            
$ratinground($calcrating);
                        }
                        
$textnl2br($entry['entrytext']);
                        
$wcv_entry$entry['whocanview'];
                        if(
$entry['private']=="1" AND in_array($bbuserinfo['userid'], explode(','$wcv_entry)))
                        {
                            eval(
'$entrybits .= "' fetch_template('journal_entrybits') . '";');
                        }
                        elseif(
$bbuserinfo['usergroupid']=="6")
                        {
                            eval(
'$entrybits .= "' fetch_template('journal_entrybits') . '";');
                        }
                        elseif(
$bbuserinfo['userid'] == $journalinfo['journalist_id'])
                        {
                            eval(
'$entrybits .= "' fetch_template('journal_entrybits') . '";');
                        }
                        elseif(
$entry['private']!="1")
                        {
                            eval(
'$entrybits .= "' fetch_template('journal_entrybits') . '";');
                        }
                        else
                        {
                            
$entrybits="";
                        }
                    }
                }
                eval(
'print_output("' fetch_template('journal_journalpage') . '");'); 
Reply With Quote
  #5  
Old 04-20-2004, 12:43 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone?
Reply With Quote
  #6  
Old 04-21-2004, 01:48 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

please anyone?
Reply With Quote
  #7  
Old 04-22-2004, 10:12 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

?????
Reply With Quote
  #8  
Old 04-22-2004, 11:40 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you mean the result is blank, or that it's not ordering the way you want it to?

Also never EVER place queries within a mysql_fetch_array loop, unless you want to call massive amounts of un-needed queries on your page. A simple LEFT JOIN in your first query can solve this.

Oh, if you had released this as a hack, people would get pissed to find out you left it easily open to MySQL injection. Never insert a direct $_REQUEST/$_GET/$_POST into a query, one could exit the query and call another statement to do malicious things, like drop your database. The vBulletin globalize() function is the first step to securing variables, and the second is to use addslashes() on ANY STRING VARIABLE inside a query.

Also, it's unnecessary to put single quotes around integer values in a SQL string. Reserve them for strings.

Bad:
PHP Code:
                    while($entry$DB_site->fetch_array($fentries))
                    {
                        
$count$DB_site->query_first("SELECT COUNT(*) AS comments FROM ".TABLE_PREFIX."journal_comments WHERE journal_id='".$_REQUEST['j']."' AND entry_id='".$entry['entry_id']."'"); 
Good
PHP Code:
// this will explicitly cast 'j' as an int, and you can now use it as $j
globalize($_REQUEST, array(
     
'j' => INT
));

$fentries $DB_site->query("
     SELECT journal_entries.entry_id, journal_entries.entrytitle, 
    journal_entries.entrytext, journal_entries.entrydate, 
     journal_entries.entry_totalvotes, journal_entries.entry_totalrating, 
    journal_entries.private, journal_entries.whocanview, 
    COUNT(journal_comments.*) AS comments 
    FROM "
.TABLE_PREFIX."journal_entries 
    LEFT JOIN journal_comments 
    USING (journal_id) 
    WHERE journal_id=
$j 
    AND entry_active=1     
     ORDER BY entrydate ASC
 "
);
 
 while (
$fentry $DB_site->fetch_array($fentries)
 {
     echo 
"Number of comments in this journal: $fentry[comments]";
 } 
This assumes your `journal_comments` has a `journal_id` field.
Reply With Quote
  #9  
Old 04-23-2004, 12:46 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oh didnt know i could do that with globalize, thanks
Reply With Quote
  #10  
Old 04-24-2004, 10:02 PM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im getting an mysql error using that code you gave me

Quote:
Originally Posted by mysql
Invalid SQL:
SELECT journal_entries.entry_id, journal_entries.entrytitle,
journal_entries.entrytext, journal_entries.entrydate,
journal_entries.entry_totalvotes, journal_entries.entry_totalrating,
journal_entries.private, journal_entries.whocanview,
COUNT(journal_comments.*) AS comments
FROM journal_entries
LEFT JOIN journal_comments
USING (journal_id)
WHERE journal_id='6'
AND entry_active='1'
ORDER BY entrydate ASC

mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS comments
FROM journal_entries
LEFT JOIN
you know wuts wrong?
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:01 AM.


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.05752 seconds
  • Memory Usage 2,293KB
  • 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
  • (3)bbcode_php
  • (2)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