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
https://forums.phpfreaks.com/topic/283427-can-update-database/
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
https://forums.phpfreaks.com/topic/283427-can-update-database/#findComment-1456297
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.