Announcement

Collapse
No announcement yet.

Using a date with PHP/MySQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a date with PHP/MySQL

    Well I'm starting to make a new news system for my website and I can't get the date to save 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['news'] == "add")
    {
    $date date("l, F d, Y");
    eval(
    'print_output("' fetch_template('site_v3_admin_news_add') . '");');
    }
    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`='"
    .$vbulletin->GPC['id']."'";
         
    $db->query_write($sql);
         
    // Send the output.
         
    $id $vbulletin->GPC['id'];
    $vbulletin->url "index.php?" $vbulletin->session->vars['sessionurl'] ."page_id=$id";
    eval(
    print_standard_redirect('redirect_Save_page'truetrue));  
    }
    if (
    $_REQUEST['save'] == "news")
    {
    //------------------------------------------------------------
    // 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 "site_news
          (newstitle, date, newsauthor, newsartcle) VALUES ('"
    .$db->escape_string($vbulletin->GPC['name'])."','".$vbulletin->GPC['date']."','".$db->escape_string($vbulletin->userinfo['username'])."','".$db->escape_string($vbulletin->GPC['description'])."')";
         
    $db->query_write($sql);

     
    ?>

  • #2
    Add 'date' to the clean_array_gpc in the statement aboive the INSERT.
    Want to take your board beyond the standard vBulletin features?
    Visit the official Member to Member support site for vBulletin Modifications: www.vbulletin.org

    Comment


    • #3
      thanks!

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X