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->userinfo, 11) AND !is_member_of($vbulletin->userinfo, 6))
{
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!