Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


    error data truncated for column

    Share

    anysha
    Ahli Baharu
    Ahli Baharu

    Number of posts : 19
    Registration date : 08/06/2009

    error data truncated for column

    Post by anysha on Tue Jun 09, 2009 12:46 pm

    sy xterer php n mysql.mmg sengal2 ayam jer ney.pastu dpt plak error cmni.ape mmaksud error nih eh?? kt cni sy bg code utk mereka2 yg expert untuk membantu..huhu..

    +++++++++++++++++++++++++++++++++++++++++++++
    mysql script
    +++++++++++++++++++++++++++++++++++++++++++++


    mysql> create table maklumat(lot varchar(20) primary key not null, nama varchar(150) default null, KP varchar(12) default null,
    rumah varchar(255) default null, luas float(6,4) default 0.0000, t_Warta date,
    t_Bicara date, t_BorangH date, noEft int(20), t_Eft date,
    t_BorangK date, bayaran2008 double(10,2) default 0.00, jum double(10,2) default 0.00, jumNilaian
    double(10,2) default 0.00, catatan text);

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    display page script (error tuh akn kua kt page nih kalu field KP, luas, rumah dan seterusnya x diisi
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <?php

    $host="localhost";
    $user="root";
    $pass="anysha";
    $db_name="test";
    $tbl_name="maklumat";

    $conn=mysql_connect("$host", "$user", "$pass") or die("cannot connect");
    mysql_select_db($db_name, $conn) or die("Unable to select database");

    /*TAK SIAP LAGI NEY..CEK BALIK*/
    $day1 = $_POST['day1'];
    $month1 = $_POST['month1'];
    $year1 = $_POST['year1'];
    $t_Warta = "$year1-$month1-$day1";


    $day2 = $_POST['day2'];
    $month2 = $_POST['month2'];
    $year2 = $_POST['year2'];
    $t_Bicara = "$year2-$month2-$day2";

    $day3 = $_POST['day3'];
    $month3 = $_POST['month3'];
    $year3 = $_POST['year3'];
    $t_BorangH = "$year3-$month3-$day3";

    $day4 = $_POST['day4'];
    $month4 = $_POST['month4'];
    $year4 = $_POST['year4'];
    $t_Eft = "$year4-$month4-$day4";


    $day5 = $_POST['day5'];
    $month5 = $_POST['month5'];
    $year5 = $_POST['year5'];
    $t_BorangK = "$year5-$month5-$day5";



    /*insert into data table*/
    $lot = $_POST['lot'];
    $nama = $_POST['nama'];
    $KP = $_POST['KP'];
    $rumah = $_POST['rumah'];
    $luas = $_POST['luas'];
    $noEft = $_POST['noEft'];
    $bayaran2008 = $_POST['bayaran2008'];
    $jum = $_POST['jum'];
    $jumNilaian = $_POST['jumNilaian'];
    $catatan = $_POST['catatan'];

    if(!isset($lot))$lot="";
    if(!isset($name))$name="";
    if(!isset($KP))$KP="";
    if(!isset($rumah))$rumah="";
    if(!isset($luas))$luas="";
    if(!isset($noEft))$noEft="";
    if(!isset($bayaran2008))$bayaran2008="";
    if(!isset($jum))$jum="";
    if(!isset($jumNilaian))$jumNilaian="";


    $query="INSERT INTO maklumat(lot, nama, KP, rumah, luas, t_Warta,
    t_Bicara, t_BorangH, noEft, t_Eft,
    t_BorangK, bayaran2008, jum, jumNilaian, catatan) VALUES ('$lot','$nama', '$KP', '$rumah', '$luas', '$t_Warta', '$t_Bicara', '$t_BorangH', '$noEft', '$t_Eft', '$t_BorangK', '$bayaran2008', '$jum', '$jumNilaian', '$catatan')";

    $result=mysql_query($query);

    if($result){
    echo "THANK YOU! 1 new data added";
    echo "<br>";
    }
    else {
    echo "Error " .mysql_error();
    }


    mysql_close();

    ?>

    <html>
    <body>
    <br>
    <h4>LOT NOMBOR:<?php echo $lot; ?><br>
    NAMA PEMILIK:<?php echo $nama; ?><br>
    NO KP:<?php echo $KP; ?><br>
    RUMAH TERLIBAT:<?php echo $rumah; ?><br>
    LUAS DIAMBIL:<?php echo $luas; ?><br>
    TARIKH WARTA:<?php echo $t_Warta; ?><br>
    TARIKH BICaRA:<?php echo $t_Bicara; ?><br>
    TARIKH BORANG H:<?php echo $t_BorangH; ?><br>
    NOMBOR EFT/CEK:<?php echo $noEft; ?><br>
    TARIKH EFT:<?php echo $t_Eft; ?><br>
    TARIKH BORANG K:<?php echo $t_BorangK; ?><br>
    BAYARAN 2008:<?php echo $bayaran2008; ?><br>
    JUMLAH:RM<?php echo $jum; ?><br>
    JUMLAH NILAIAN:RM<?php echo $jumNilaian; ?><br>
    CATATAN:<?php echo $catatan; ?><br></h4>
    </body>
    </html>





    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    panjangnye...
    Evil or Very Mad hrp2 fhm la prob sy ni yer..

    SHiDi
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 30
    Age : 32
    Location : Ampang
    Job/hobbies : Geek
    Registration date : 03/03/2009

    Re: error data truncated for column

    Post by SHiDi on Wed Jun 10, 2009 1:32 pm

    Error ni biasanya merujuk kepada percanggahan antara foreign key dengan actual key. Tunjuk kan schema table tu dan juga table yang dirujuk oleh foreign key.

    Sebab ni rasanya memang tiada kaitan dengan SQL query. Cool

    Hansz
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 184
    Age : 29
    Location : Kuala Kangsar, Perak
    Job/hobbies : PHP, Design, Developing, Composing, Computer
    Registration date : 01/06/2009

    Re: error data truncated for column

    Post by Hansz on Thu Jun 11, 2009 12:23 am

    anysha wrote:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    panjangnye...
    :evil: hrp2 fhm la prob sy ni yer..

    Macam mana nak tolong, ERROR tu pun tak paste kat sini :(

    Copy and Paste ERROR tu, insyaAllah boleh dibantu.

    And Query tu, cuba tukar jadi macam ni jer :

    Code:
    $query="INSERT INTO maklumat(lot, nama, KP, rumah, luas, t_Warta,
    t_Bicara, t_BorangH, noEft, t_Eft,
    t_BorangK, bayaran2008, jum, jumNilaian, catatan) VALUES ('".$_POST['lot']."','".$_POST['nama']."', '".$_POST['KP']."', '".$_POST['dan_bla_bla_bla'].")";

    // Yang guna Day-Month-Year tu bleh tukar jadi :

    Code:
    '"".$_POST['day12345']."-".$_POST['month12345']."-".$_POST['year12345'].""'

    anysha wrote:
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    display page script (error tuh akn kua kt page nih kalu field KP, luas, rumah dan seterusnya x diisi
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Cuba guna cara ni,

    // Check kesilapan sebelum hantar dalam database

    Code:

    // Pastikan pembuka "(" dan penutup ")" mencukupi :p
    if ((!isset($lot))AND(!isset($KP))AND(!isset($luas))AND(!isset($rumah))AND(!isset($blablabla))) { echo"Requied field cannot be left blank !"; } else { $result=mysql_query($query); }

    Note : Cuma sekadar cadangan...

    anysha
    Ahli Baharu
    Ahli Baharu

    Number of posts : 19
    Registration date : 08/06/2009

    Re: error data truncated for column

    Post by anysha on Mon Jun 15, 2009 2:25 pm

    thanks guys! prob ney dh setel! Wink

    Sponsored content

    Re: error data truncated for column

    Post by Sponsored content Today at 7:11 am


      Current date/time is Sat Dec 10, 2016 7:11 am