2016-04-15 56 views
0

目前我正在試圖運行從URL ID更新ID,我可以找回ID但是有什麼不對勁我的更新,真的不知道我要去哪裏錯了更新與URL

require_once'connection.php'; 



     $getCode = $db->prepare(" 
         SELECT username, activecode FROM username WHERE activecode = ? 
        "); 
     $getCode->execute(array ($_GET["activecode"])); 


$sql = "UPDATE `username` SET `active` = '1' 
    WHERE `activecode` = :activecode"; 

// var_dump($sql); 
    $stmt = $db->prepare($sql); 
    $stmt->bindParam(':activecode', $getCode); 
    $stmt->execute(); 

回答

1
<?php 
    require_once'connection.php'; 
    $getCode = $db->prepare(" SELECT username, activecode FROM username WHERE activecode = :activecode"); 
    $getCode->bindParam(':activecode', $_GET["activecode"]); 
    $getCode->execute(); 


    $sql = "UPDATE username SET active = '1' WHERE activecode = :activecode"; 
// var_dump($sql); 
$stmt = $db->prepare($sql); 
$stmt->bindParam(':activecode', $_GET["activecode"]); 
$stmt->execute(); 
?> 
+0

啊,沒想到,謝謝 –