vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Sql... (https://vborg.vbsupport.ru/showthread.php?t=119603)

rogersnm 06-25-2006 10:33 AM

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?

Guest190829 06-25-2006 10:37 AM

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.

rogersnm 06-25-2006 10:39 AM

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).

Paul M 06-25-2006 11:38 AM

$chocolate is an array of the columns you requested in the query. You need to use $chocolate['column1']

rogersnm 06-25-2006 11:44 AM

1 Attachment(s)
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.

Paul M 06-25-2006 12:36 PM

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); 


rogersnm 06-25-2006 12:44 PM

Thanks mate, works now. With a few tweaks.


All times are GMT. The time now is 01:11 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.00995 seconds
  • Memory Usage 1,743KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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