开发者

Update not working for MySQL and PHP

I am trying to update the entry in the database i have encrypted the field uniqueID

May be encrypted field uniqueId causing 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))
{
    $dbuniqu开发者_JAVA百科eID = 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);  
    }
} 


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']) . "'";


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜