vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   could some one help me with this code (https://vborg.vbsupport.ru/showthread.php?t=111031)

DrewM 03-21-2006 10:12 PM

could some one help me with this code
 
Well I'm making a page where you can add, edit pages the add is fine but the edit is not saving to the data base right my php code is:
PHP Code:

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

// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''Adminpages');

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

$specialtemplates = array();

// pre-cache templates used by all actions 
$globaltemplates = array( 
        
'site_admin_add',
        
'site_admin_edit',
);

$actiontemplates = array();

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

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

$navbits = array(); 
$navbits[$parent] = admin

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

 
// ################ SHOW NO PERMISSION PAGE TO GUESTS ####################

if (!is_member_of($vbulletin->userinfo11) AND !is_member_of($vbulletin->userinfo6)) 

        
print_no_permission(); 
}  

// ########################### ADD THE SITE ##############################

if ($_REQUEST['do'] == "add")
{
eval(
'print_output("' fetch_template('site_admin_add') . '");');
}

if (
$_REQUEST['do'] == "edit")
{
$var "SELECT * FROM " TABLE_PREFIX "page WHERE page_id='".intval($_REQUEST['id'])."'";
$sqlr $db->query_read($var);
$sr $db->fetch_array($sqlr);
eval(
'print_output("' fetch_template('site_admin_edit') . '");');
}

if (
$_REQUEST['save'] == "add")
{
//------------------------------------------------------------
// Add the site to the database if everything is ok.
//------------------------------------------------------------
    // Sanitize User Submitted Data
    
$vbulletin->input->clean_array_gpc('p', array(
    
'name' => TYPE_STR,
    
'description' => TYPE_STR
    
));
        
$sql "INSERT INTO " TABLE_PREFIX "page
      (page_name, page_edit_by, page_status, page_contents) VALUES ('"
.$db->escape_string($vbulletin->GPC['name'])."','".$db->escape_string($vbulletin->userinfo['username'])."','1','".$db->escape_string($vbulletin->GPC['description'])."')";
                
$db->query_write($sql);
}    
 
    if (
$_REQUEST['save'] == "edit")
    {
//------------------------------------------------------------
// Update the site if everything is ok.
//------------------------------------------------------------
    
$vbulletin->input->clean_array_gpc('p', array(
    
'id' => TYPE_UINT,
    
'name' => TYPE_STR,
    
'description' => TYPE_STR
    
));

                    
$sql "UPDATE " TABLE_PREFIX "page set
                page_name='"
.$db->escape_string($vbulletin->GPC['name'])."',
                page_contents='"
.$db->escape_string($vbulletin->GPC['description'])."',    
                WHERE page_id='"
.intval($_REQUEST['id'])."'";
                    
$db->query_write($sql);

                    
// Send the output.
                    
$id $vbulletin->GPC['id'];
}

?>

My error is:
Quote:

Database error in vBulletin 3.5.4:

Invalid SQL:
UPDATE page set
name='Eps',
description='OFB Info Movies Pictues',
WHERE page_id='2';

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 'WHERE page_id='2'' at line 4
Error Number : 1064
HELP is very much appricated!

DrewM 03-22-2006 10:13 PM

bump

Paul M 03-22-2006 11:49 PM

Try this;

PHP Code:

$sql "UPDATE " TABLE_PREFIX "page set 
page_name='"
.$db->escape_string($vbulletin->GPC['name'])."', 
page_contents='"
.$db->escape_string($vbulletin->GPC['description'])."',     
WHERE page_id="
.intval($_REQUEST['id']); 


DrewM 03-23-2006 08:49 AM

thankls will try

Still getting error it's
Quote:

Database error in vBulletin 3.5.4:

Invalid SQL:
UPDATE page set
page_name='Eps',
page_contents='OFB Info Movies Pictues',
WHERE page_id=2;

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 'WHERE page_id=2' at line 4
Error Number : 1064
got it it's:
WHERE `page_id`='".$vbulletin->GPC['id']."'";


All times are GMT. The time now is 04:25 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.01874 seconds
  • Memory Usage 1,756KB
  • 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_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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