vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Arghh, mysql insert not working in VB (https://vborg.vbsupport.ru/showthread.php?t=112389)

Jaynesh 04-07-2006 12:44 PM

Arghh, mysql insert not working in VB
 
:tired: I have been trying to get it to insert values into a table.

Ive intergrated it with vBulletin and its database, but it just does not insert the values.

I receive no error message.

PHP Code:

<?php

// ######################## SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// ##################### DEFINE IMPORTANT CONSTANTS ####################### 
// change the line below to the actual filename without ".php" extention. 
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation. 

define('THIS_SCRIPT''test');  

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array(); 

// get special data templates from the datastore 
$specialtemplates = array(); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
        
// change the lines below to the list of actual templates used in the script 
        
'quotegen'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array(); 

// ########################## REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// #################### HARD CODE JAVASCRIPT PATHS ######################## 
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 

$navbits = array();  
// change the line below to contain whatever you want to show in the navbar (title of your custom page) 
$navbits[$parent] = 'Test Page'

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 

// change the line below to contain the name of the actual main output template used in your script 
eval('print_output("' fetch_template('quotegen') . '");');

$vbulletin->db->query_write("INSERT INTO quotegen VALUES ('hello')");
?>

What am i doing wrong?

peterska2 04-07-2006 02:11 PM

I'm not a php expert by a long way, but it looks like the problem is here
Code:

$vbulletin->db->query_write("INSERT INTO quotegen VALUES ('hello')");
I believe it should be
Code:

$db->query_write("INSERT INTO quotegen VALUES ('hello')");
If I'm wrong I apologise, but looking at similar queries in vB, it is always set out the second way.

Jaynesh 04-07-2006 02:48 PM

Doesnt work :(

sabret00the 04-07-2006 03:58 PM

having not provided the error messge, i'm not totally sure, but...

PHP Code:

$vbulletin->db->query_write("INSERT INTO quotegen(colname) VALUES ('hello')"); 


Jaynesh 04-07-2006 04:51 PM

I get no error message. it just does not insert into the table

Aesma Deva 04-08-2006 10:26 AM

Try adding the column where you want to add the data, like this:
PHP Code:

$db->query_write("INSERT INTO quotegen (column_name) VALUES ('hello')"

(Replace column_name with the name of the column you want to add your data at)

akanevsky 04-08-2006 01:18 PM

I believe that the query is not executed because it's placed after print_output.

sabret00the 04-08-2006 02:13 PM

Quote:

Originally Posted by Psionic Vision
I believe that the query is not executed because it's placed after print_output.

yup you're right, totally missed that, print_output had a die in there.

Jaynesh 04-09-2006 08:59 AM

Aesma Deva, Tried that never worked :(

Psionic Vision, sabret00the, How would i fix it, im a newbie to php:(

sabret00the 04-09-2006 09:06 AM

PHP Code:

<?php

// ######################## SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// ##################### DEFINE IMPORTANT CONSTANTS ####################### 
// change the line below to the actual filename without ".php" extention. 
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation. 

define('THIS_SCRIPT''test');  

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array(); 

// get special data templates from the datastore 
$specialtemplates = array(); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
        
// change the lines below to the list of actual templates used in the script 
        
'quotegen'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array(); 

// ########################## REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// #################### HARD CODE JAVASCRIPT PATHS ######################## 
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 


$vbulletin->db->query_write("INSERT INTO quotegen VALUES ('hello')");

$navbits = array();  
// change the line below to contain whatever you want to show in the navbar (title of your custom page) 
$navbits[$parent] = 'Test Page'

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 

// change the line below to contain the name of the actual main output template used in your script 
eval('print_output("' fetch_template('quotegen') . '");');
?>



All times are GMT. The time now is 08:39 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.01133 seconds
  • Memory Usage 1,767KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete