samanj Posted December 28, 2020 Share Posted December 28, 2020 Hi everyone, My code is meant to give a certain response if the hospital number & PIN together do or do not match. However, whatever I input, whether it is correct information or random numbers, I still get the output that the data has been submitted successfully. Any thoughts? <?php $connect = mysqli_connect($hostname, $username, $password, $databaseName); $query = "UPDATE card SET comments = '$comments' , seniorsent = '$seniorsent' WHERE hospitalnumber = '$hospitalnumber' and PIN = '$PIN'"; @mysqli_query($connect, $query); $result = mysqli_query($connect, $query); if($result) { echo 'Data submitted successfully'; }else{ echo 'Please check that all details are correct'; } > Thanks in advance, samanj Quote Link to comment https://forums.phpfreaks.com/topic/311942-data-not-matching-but-code-does-not-acknowledge-this/ Share on other sites More sharing options...
Barand Posted December 28, 2020 Share Posted December 28, 2020 Check the number of affected rows to see if any rows were updated. Not finding a record is not a query failure. Quote Link to comment https://forums.phpfreaks.com/topic/311942-data-not-matching-but-code-does-not-acknowledge-this/#findComment-1583496 Share on other sites More sharing options...
samanj Posted December 28, 2020 Author Share Posted December 28, 2020 Ok thank you, I will check the number of rows. I think that will do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/311942-data-not-matching-but-code-does-not-acknowledge-this/#findComment-1583498 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.