tags:

views:

55

answers:

3

hi all, I am trying to update the entry in the database i ahve encrypted the field uniqueID

i think that is causing some problem.

$query  = "SELECT UniqueID FROM configuration";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
echo $num_rows;
while($row = mysql_fetch_assoc($result))
{
 $dbuniqueID = Encryption::decrypt($row['UniqueID']);

 if($dbuniqueID == $UniqueID) 
 {
 // $UniqueID = Encryption::encrypt($UniqueID);
  echo $UniqueID;
  $insert = "UPDATE configuration SET status = 'ready', original_conf_path = '$Filepath'
   WHERE UniqueID = '$UniqueID'";
   mysql_query($insert);  
 }
}

Regards Newbie

A: 
$insert = "UPDATE configuration SET status = 'ready', SET original_conf_path = '".$Filepath."' WHERE UniqueID = '".$UniqueID."'";
Priyank Bolia
A: 

Well the problem is here: WHERE UniqueID = '$UniqueID'";

cause $UniqueID holds a decrypted value so UniqueID in database is different from that in variable.

But if $UniqueID holds encrypted value than this line won't work: if($dbuniqueID == $UniqueID

cause you are comparing encrypted and decrypted values

dfilkovi
+1  A: 

There is no $UniqueID for your comparison or insert - it should be $row['UniqueID']

$insert = "UPDATE configuration SET status = 'ready', original_conf_path = '$Filepath'
             WHERE UniqueID = '$row[UniqueID]'";

You should also escape it:

    $insert = "UPDATE configuration SET status = 'ready',
        original_conf_path = '" . mysql_escape_string($Filepath) . "'
        WHERE UniqueID = '" . mysql_escape_string($row['UniqueID']) . "'";
Greg
Many thanks Greg it works....
NewBie
now i have added one column in DB and Update is not working agian
NewBie
$insert = "UPDATE configuration SET status = 'ready', original_conf_path = '" . mysql_escape_string($Filepath) . "' WHERE UniqueID = '" . mysql_escape_string($row['UniqueID']) . "'"; mysql_query($insert);
NewBie
i found where the issue is i am not able to inset the path properly C:\aksjdh\asd\asd
NewBie