Issue with update

I am new to php and having an issue. I am using the code so when our software program becomes unregistered, it hits this script and changes the registration code from the actual number to ----removed-----. I got the program to work, however it put ----removed----- on all of the registration codes not just the one that was submitted. This code orginally came from our registration program and i am trying to modify it so it will unregister. I have // out some of the code that was used for registration.
Thanks,
Ben


<?php
/* datbase connectino */
	include_once "conn.php";
	$con=new connection();

/* geting values on request */
	$install_regcode=$_REQUEST['install_regcode'];
	$install_computer=$_REQUEST['install_computer'];
	$install_school=$_REQUEST['install_school'];


$sql_install="select * from ezy_installs where install_regcode='$install_regcode'";
		$query_install=mysql_query($sql_install);
		$num_rows_install=mysql_num_rows($query_install);
//if($num_rows_install<'3'){

				 $sql="select * from ezy_installs where 
					install_regcode='$install_regcode' and 
					install_computer='$install_computer'";
					$query=mysql_query($sql);
//$num_rows=mysql_num_rows($query);
					$remove = '---Removed---';
					if($num_rows=='0'){
						$sql_ins="update ezy_installs set 
							install_regcode='$remove'";
						$query_ins=mysql_query($sql_ins);
						$message="success";
//	} else {
//	$message="success";
//			}
			} else {
			$message="failure";
			}
		
//	} else {
//		$message="failure";
//	}
	
	 if($message=="success") {
	 $status_attribute="1";
	 } else {
	  $status_attribute="0";
	 }

function xml_response($status_attribute, $message){
/////////// Generating xml file on xml result ///////////////////////
$result_value='<?xml version="1.0" encoding="UTF-8" ?>
<software4schools>
	<status value="'.$status_attribute.'">'.$message.'</status>
</software4schools>';
	
	$testob=$result_value;
	$myFile = "xml/transaction.xml";
	$fh = fopen($myFile, 'w+') or die("can't open file");
	$m = fwrite($fh,$testob);
	
	fclose($fh);
	@chmod($myFile,0777);
}
	 xml_response($status_attribute, $message);
// } else {
	echo "Direct access of this file is not allowed.";
//}
?>


$sql_ins="update ezy_installs set install_regcode='$remove'";

You’re going to need a WHERE part in your SQL query to specify which regcode it should remove ;) Right now the MySQL engine is not restricted to certain rows and will indiscriminately change -all- regcodes to removed.

Ohhh,
I was thinking that the select statement was narrowing down to that one transaction.
Thank you,

Sponsor our Newsletter | Privacy Policy | Terms of Service