Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    failed to update DB

    hey guys,.. i need some help here..
    i try to update my data from mysql database but it seem my syntaks wrong but i cann't figure out where the wrong side??

    here my code
    PHP Code:
    $anggota=new member();
        
    $anggota->userName=$_COOKIE['user'];
        
    $anggota->namaMember=$_POST['nama'];
        
    $anggota->alamatMember=$_POST['alamat'];
        
    $anggota->handphoneMember=$_POST['hp'];
        
    $anggota->noTelpMember=$_POST['notelp'];
        
    $anggota->alamatMember1=$_POST['alamat2'];
        
    $anggota->kotaMember=$_POST['kota'];
        
    $anggota->provinsiMember=$_POST['provinsi'];
        
    $anggota->kodeposMember=$_POST['kode'];
        
    $anggota->sintaks="UPDATE member SET Nama='$anggota->namaMember',NoTelp='$anggota->noTelpMember',Handphone='$anggota->handphoneMember',Alamat='$anggota->alamatMember',Alamat2='$anggota->alamatMember1',Kota='$anggota->kotaMember',Provinsi='$anggota->provinsiMember',Kode Pos='$anggota->kodeposMember' WHERE Username='$anggota->userName'";
        
    $isi=$anggota->memberMain($anggota);
        
    $result=mysql_affected_rows($isi);
        echo 
    $result." row affected:::"
    here the class code:
    PHP Code:

    include "connect.php";
    class 
    member
    {
        public 
    $idMember;
        public 
    $userName;
        public 
    $passwordMember;
        public 
    $namaMember;
        public 
    $handphoneMember;
        public 
    $noTelpMember;
        public 
    $alamatMember;
        public 
    $alamatMember1;
        public 
    $emailMember;
        public 
    $kotaMember;
        public 
    $provinsiMember;
        public 
    $kodeposMember;
        public 
    $sintaks;
        
        public function 
    memberMain($member)
        {
            
    $hasil=$member->sql();
            return 
    $hasil;
        }
        public function 
    sql()
        {
            
    $koneksi=new DatabaseConnectClass();
            
    $koneksi->database_hostname="localhost";
            
    $koneksi->database_username="Dewa";
            
    $koneksi->database_password="pa";
            
    $koneksi->database_name="pa";
            
    $koneksi->databaseConnectionMain($koneksi);
            
    $set_query=mysql_query($this->sintaks)or die("GAGAL KARENA ".mysql_error());
            
    mysql_close();
            return 
    $set_query;
        }

    and this is the error message :: "GAGAL KARENA 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 'Pos='' WHERE Username='lupin'' at line 1"

    thank you before for everyone that willing give me some suggest!!

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Wrong field name "Kode Pos", do you really have a field with such name?

  • Users who have thanked poyzn for this post:

    batubatamerah (11-22-2010)

  • #3
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by poyzn View Post
    Wrong field name "Kode Pos", do you really have a field with such name?
    yeah i really have it,..
    but from what you say i try to change the name to kode_pos without spasi and it works... ty..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •