简体   繁体   中英

Update prepared statement not working

This SQL isn't working and I'm trying to fix it for hours with rowCount() and print_r($array) but no luck.

Appreciate all help!

$sql=" UPDATE Listing SET 
        rentStartDate = :rentStartDate,
        rentEndDate = :rentEndDate,
        backyard = :backyard,
        pricePerMonth = :pricePerMonth,
        noOfBathrooms = :noOfBathrooms,
        roomCapacity = :roomCapacity,
        currentNoOfuser = :currentNoOfuser,
        accessToPublicTrans = :accessToPublicTrans,
        parkingSpace = :parkingSpace,
        minimumLengthOfStay = :minimumLengthOfStay 
        WHERE address = :address ";

    $stmt = $db->prepare($sql);

    $stmt->bindValue(':address',  $address);  
    $stmt->bindValue(':rentStartDate', $rentStartDate);  
    $stmt->bindValue(':rentEndDate', $rentEndDate);  
    $stmt->bindValue(':backyard', $backyard);  
    $stmt->bindValue(':pricePerMonth', $pricePerMonth);  
    $stmt->bindValue(':noOfBathrooms', $noOfBathrooms);  
    $stmt->bindValue(':roomCapacity', $roomCapacity);  
    $stmt->bindValue(':currentNoOfuser', $currentNoOfuser);  
    $stmt->bindValue(':accessToPublicTrans', $accessToPublicTrans);
    $stmt->bindValue(':parkingSpace', $parkingSpace);
    $stmt->bindValue(':minimumLengthOfStay', $minimumLengthOfStay);       

    $stmt->execute(); 

Try this like:

$sql=" UPDATE Listing SET 
        rentStartDate = ?,
        rentEndDate = ?
        WHERE address = ?";

    $stmt = $db->prepare($sql);

    $stmt->bind_param('sss',  $rentStartDate,$rentEndDate,$address);  

    $stmt->execute(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM