Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

cannot update my database

Codes here !

Moderators: macek, egami, gesf

cannot update my database

Postby juraganerka » Tue Oct 29, 2013 10:17 pm

i want to update my database,but unfortunately not change.
anyone can help me.i can't solved it over 1 week.
please.
this is my code:
Code: Select all
include "new.php";
$response = array();
if (isset($_GET['ID_Person']) && isset($_POST['FirstName']) && isset($_POST['MiddleName']) && isset($_POST['LastName'])
 && isset($_POST['AliasName']) && isset($_POST['Gender'])    && isset($_POST['CityBirth'])  && isset($_POST['DateBirth'])
 && isset($_POST['MonthBirth'])&& isset($_POST['YearBirth']))
 
{

$id       =  $_GET ['ID_Person'];
$name       =  $_POST['FirstName'];
$middle    =  $_POST['MiddleName'];
$last      =  $_POST['LastName'];
$alias       =  $_POST['AliasName'];
$gender    =  $_POST['Gender'];
$citybirth    =  $_POST['CityBirth'];
$datebirth    =  $_POST['DateBirth'];
$monthbirth =  $_POST['MonthBirth'];
$yearbirth    =  $_POST['YearBirth'];

$query = "update T_Person set First_Name_Person    = '$name'    ,
               Middle_Name_Person   = '$middle'    ,
               Last_Name_Person      = '$last'    ,
                Alias_Person       = '$alias'   ,
                              Gender_Person      = '$gender'   ,
                 City_Birth_Person    = '$citybirth',
                 Date_Birth_Person    = '$datebirth',
               Month_Birth_Person   = '$monthbirth',
                          Year_Birth_Person    = '$yearbirth'
               where ID_Person       = '$id'";
                                      
$hasil = sqlsrv_query($conn,$query,$response);
$rows_affected = sqlsrv_rows_affected($hasil);

   if ($rows_affected() === false)
   {
         // jika gagal update
      $response["sukses"] = 1;
          $response["pesan"] = "Member berhasil diupdate";
        // memprint/mencetak JSON respon
        echo json_encode($response);
   }      
   else {
   // jika gagal di update
        $response["sukses"] = 0;
        $response["pesan"] = "Gagal update";

        // memprint/mencetak JSON respon
        echo json_encode($response);
         }
}   else {
    // jika data tidak terisi/tidak terset
    $response["sukses"] = 0;
    $response["pesan"] = "data belum terisi";

    // memprint/mencetak JSON respon
    echo json_encode($response);
        }
juraganerka
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Oct 29, 2013 10:13 pm

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.