Jump to content

can update database


juraganerka

Recommended Posts

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:

<?
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);
		  }
		  

?>		  
Link to comment
Share on other sites

 

Your trying to call a function here. 

if ($rows_affected() === false) 

The variable $rows_affected contains the number of rows the query updated. Not a function

 

It should be

if ($rows_affected !== false) 

i try change what u suggest but it's not working  :

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.