Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2006, 10:33 AM
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Posts: 729
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Sql...

OK so i have this:
PHP Code:
$chocolate $vbulletin->db->query_read("
SELECT column1
FROM " 
TABLE_PREFIX "test
WHERE columnfudge > '999'
LIMIT 1
"
);  
$vbulletin->db->query_write("
INSERT INTO " 
TABLE_PREFIX "test (column1,columnfudge) VALUES ('[2] $chocolate','0')
"
); 
in a cron. When the cron runs it picks up value of $chocolate (which is abc in this case) It doesn't add it as "[2] abc" and "0" it does "[2] Resource id #18" and "0". Any Ideas?
Reply With Quote
  #2  
Old 06-25-2006, 10:37 AM
Guest190829
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by rogersnm
OK so i have this:
PHP Code:
$chocolate $vbulletin->db->query_read("
SELECT column1
FROM " 
TABLE_PREFIX "test
WHERE columnfudge > '999'
LIMIT 1
"
);  
$vbulletin->db->query_write("
INSERT INTO " 
TABLE_PREFIX "test (column1,columnfudge) VALUES ('[2] $chocolate','0')
"
); 
in a cron. When the cron runs it picks up value of $chocolate (which is abc in this case) It doesn't add it as "[2] abc" and "0" it does "[2] Resource id #18" and "0". Any Ideas?
From the code above the value of $chocalate is not the what you may expect it to be, it's actually a resource variable. (As you can tell from the what you get in the database: "Resource id #18".

Use:

PHP Code:
$db->query_first 
instead of $db->query_read on your first query, since you are only pulling up one value.
Reply With Quote
  #3  
Old 06-25-2006, 10:39 AM
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Posts: 729
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it still doesn't work: now i get "[2] Array" intead of "[2] abc"

i have:
PHP Code:
$chocolate $vbulletin->db->query_first("
SELECT column1
FROM " 
TABLE_PREFIX "test
WHERE columnfudge > '999'
LIMIT 1
"
);  

$vbulletin->db->query_write("
INSERT INTO " 
TABLE_PREFIX "test (column1,columnfudge) VALUES ('[2] $chocolate','0')
"
); 
and just as reassurance when i run the query SELECT column1 FROM test WHERE columnfudge > '999' LIMIT 1; i do get the right result (abc).
Reply With Quote
  #4  
Old 06-25-2006, 11:38 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$chocolate is an array of the columns you requested in the query. You need to use $chocolate['column1']
Reply With Quote
  #5  
Old 06-25-2006, 11:44 AM
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Posts: 729
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now i get
Quote:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/nick/public_html/dev/includes/cron/autoclose.php on line 30
I attached the cron file.
Attached Files
File Type: php autoclose.php (1.3 KB, 5 views)
Reply With Quote
  #6  
Old 06-25-2006, 12:36 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are too many single quotes in that.

Since it's only one column try this ;

PHP Code:
$choc $vbulletin->db->query_first("
    SELECT column1
    FROM " 
TABLE_PREFIX "test
    WHERE columnfudge > '999'
    LIMIT 1
"
);  

$chocolate $choc['column1'];

$vbulletin->db->query_write("
    INSERT INTO " 
TABLE_PREFIX "test (column1,columnfudge) VALUES ('[2] $chocolate','0')
"
);  

$vbulletin->db->query_write("
    UPDATE test SET column1 = '[1] 
$chocolate' WHERE CONVERT( `column1` USING utf8 ) = 'abc'
"
);  

log_cron_action('Hard thing done'$nextitem); 
Reply With Quote
  #7  
Old 06-25-2006, 12:44 PM
rogersnm rogersnm is offline
 
Join Date: Apr 2006
Location: Cyberspace, UK
Posts: 729
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks mate, works now. With a few tweaks.
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:55 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.03913 seconds
  • Memory Usage 2,252KB
  • Queries Executed 14 (?)
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
  • (5)bbcode_php
  • (2)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
  • (1)postbit_attachment
  • (6)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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete