...

View Full Version : failed to update DB



batubatamerah
11-22-2010, 04:06 AM
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


$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:



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!! :):)

poyzn
11-22-2010, 05:43 AM
Wrong field name "Kode Pos", do you really have a field with such name?

batubatamerah
11-22-2010, 07:13 AM
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.. :thumbsup::thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum