Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:22:44+00:00 2026-06-03T02:22:44+00:00

hi im having little trouble at inserting date from drupal to mysql here the

  • 0

hi im having little trouble at inserting date from drupal to mysql
here the code that i’m trying

.....
$form['kotak']['tgl'] = array(
'#type' => 'date',
'#title' => t('Tanggal'),
);
.....
function awal_form_submit($form,&$form_state){
global $user;
$entry = array(
 'tanggal'  => $form_state['values']['tgl'],
);
$tabel = 'jp_1';
$return = insert_form($entry,$tabel);
}
.....
function insert_form($entry,$tabel){
$return_value = NULL;
try {
 $return_value = db_insert($tabel)
                ->fields($entry)
                ->execute();    
}
.....

everytime i’m submit, error code like this

db_insert failed. Message = SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn’t match value count at row 1, query= INSERT INTO {jp_1} (tanggal) VALUES (:db_insert_placeholder_0_month, :db_insert_placeholder_0_day, :db_insert_placeholder_0_year)

any suggestion or correction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:22:46+00:00Added an answer on June 3, 2026 at 2:22 am

    i’m finally managed to find the answer, all i need is download “Date” module and activate its “Date API”. Here the code

    .....
    $datex = '2005-1-1';
    $format = 'Y-m-d';
    $form['kotak']['tgl'] = array(
    '#type' => 'date_select',
    '#default_value' => $datex,
    '#date_format' => $format,
    '#date_year_range' => '-10:+30', 
    '#title' => t('Tanggal'),
    );
    .....
    function awal_form_submit($form,&$form_state){
    global $user;
    $entry = array(
     'tanggal'  => $form_state['values']['tgl'],
    );
    $tabel = 'jp_1';
    $return = insert_form($entry,$tabel);
    }
    .....
    function insert_form($entry,$tabel){
    $return_value = NULL;
    try {
     $return_value = db_insert($tabel)
                    ->fields($entry)
                    ->execute();    
    }
    .....
    

    and now i have no problem delivering to mysql.
    Hope that will help other drupal newbie developer like me. Thanks 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am having a little trouble here. i am trying to store and retrieve images
having a little trouble, how could I alter this mysql query so that if
I'm having a little trouble getting erlang to give me a unicode string. Here's
I'm having a little trouble controlling page-specific block display in Drupal... My URL's will
I'm new to Symfony2 (with knowledge in 1.2-1.4) and having little trouble trying to
I am having a little trouble understanding ServiceKnownType in WCF. Taken from this blog
I'm having a little trouble defining my question. Here's what I have. A mailto
I am having a little trouble trying to put a border around both rows.
I am having a little trouble trying select ids of items ordered by the
I am having a little trouble with this piece of code $('.tree-item').hover(function() { $('#_'+this.id).fadeIn().delay(500).animate({

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.