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 02-26-2006, 07:50 PM
DrewM DrewM is offline
 
Join Date: Oct 2005
Posts: 564
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default data base php error

Well I'm trying to make a page that would allow my users to send links. I have a vb page with the form but the proplem is when you hit summit it saves the data but doesn't include in the data the name, url, and description (felds in the form). The code for the php is:
PHP Code:
<?php 

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

// ##################### DEFINE IMPORTANT CONSTANTS ####################### 

define('THIS_SCRIPT''Sim2world');  

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
$phrasegroups = array(); 

$specialtemplates = array(); 

$globaltemplates = array( 
        
'site_link_add'
); 

$actiontemplates = array(); 

// ########################## REQUIRE BACK-END ############################ 
chdir('/home/rdsx667/public_html/forum/'); 
require_once(
'./global.php'); 

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

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ######################################################################## 
if ($_REQUEST['do'] == 'save')  
{  
$vbulletin->db->query_write("INSERT INTO `Links` (`id`, `Name`, `url`, `description`) VALUES ('10', '$name', '$url', '$description');");

$navbits = array();  
$navbits[$parent] = 'Sim2world'

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


eval(
'print_output("' fetch_template('site_link_add') . '");'); 

?>
the Templates content is:
HTML Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../main.css" rel="stylesheet" type="text/css">
</head>

<body>
$head_2 $headinclude 
<div align="left"><br>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td><a href="index.php">Home</a>&gt;<a href="/Cool%20stuff.php"><strong>Cool 
        stuff</strong></a></td>
    </tr>
  </table>
</div>
<div align="center"> 
  <table width="933" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td width="25%" valign="top"> $toolbar</td>
      <td width="75%" valign="top" background="../../Images/content_bg.gif"><div align="center"><img src="../../Images/header.jpg" width="747" height="102"><br>
          <font size="+5"><span class="NewsTitle"><strong><u><font size="+3">Add 
          a link!<br>
          </font></u></strong></span></font>
          <table width="598" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td width="598" height="80" valign="top" class="NewsTitle"> 
                <form name="form1" method="post" action="test.php?do=save">
                  <table width="598" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td width="598" class="NewsTitle">Name: 
                        <input type="text" name="name"></td>
                    </tr>
                    <tr> 
                      <td width="598" class="NewsTitle">Url: 
                        <input name="url" type="text" id="url"></td>
                    </tr>
                    <tr> 
                      <td valign="top" class="NewsTitle">Description:<br>
                        <textarea name="description" id="description"></textarea>
                      </td>
                    </tr>
                    <tr>
                      <td class="NewsTitle"><input type="submit" name="Submit" value="Add Link!">
                        <input type="reset" name="Submit2" value="Reset"></td>
                    </tr>
                  </table>
                </form></td>
            </tr>
          </table>
          <font size="+5"><span class="NewsTitle"><strong><u><font size="+3"> 
          </font></u></strong></span></font> <br>
          <br>
        </div></td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td valign="top"><img src="../../Images/content_bottom.jpg" width="748" height="21"></td>
    </tr>
  </table>
  <br>
  $footer<br>
</div>
</body>
</html>
Reply With Quote
  #2  
Old 02-27-2006, 08:19 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HTML Code:
 <form name="form1" method="post" action="test.php?do=save">
Should be:
HTML Code:
 <form name="form1" method="post" action="test.php">
	<input type="hidden" name="do" value="save" />
 
Change:
PHP Code:
if ($_REQUEST['do'] == 'save'

$vbulletin->db->query_write("INSERT INTO `Links` (`id`, `Name`, `url`, `description`) VALUES ('10', '$name', '$url', '$description');"); 

To:
PHP Code:
if ($_REQUEST['do'] == 'save'
{
    
$vbulletin->input->clean_array_gpc('p', array(
        
'name'                => TYPE_STR,
        
'url'                    => TYPE_STR,
        
'description'    => TYPE_STR
        
));
 
    
$vbulletin->db->query_write("INSERT INTO `Links` (`id`, `Name`, `url`, `description`) 
            VALUES ('10'
            ,    '" 
$vbulletin->db->escape_string($vbulletin->GPC['name']) . "'
            ,    '" 
$vbulletin->db->escape_string($vbulletin->GPC['url']) . "'
            ,    '" 
$vbulletin->db->escape_string($vbulletin->GPC['description']) . "'
            );"
); 

Reply With Quote
  #3  
Old 02-27-2006, 09:14 AM
DrewM DrewM is offline
 
Join Date: Oct 2005
Posts: 564
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks, I'm testing it now!

EDIT: It works thanks again
Reply With Quote
  #4  
Old 03-11-2006, 06:20 PM
DrewM DrewM is offline
 
Join Date: Oct 2005
Posts: 564
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this was working fie but I have the idea auto go up so how do I get rid of the id.
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 10:24 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.03694 seconds
  • Memory Usage 2,229KB
  • 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_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete