Nematode128 Posted April 10, 2020 Share Posted April 10, 2020 $sql = "SELECT * from updates ORDER BY id DESC LIMIT 3"; $stmt = $link->prepare($sql); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows = '0') { echo "There haven't been any updates yet."; } else { echo "There are news posts"; } Gives me the error "Cannot write property in /home/evoarena/public_html/Dev/news.php:14 ", line 14 is the if statement. How can I fix it? " Quote Link to comment https://forums.phpfreaks.com/topic/310528-help-using-num-rows/ Share on other sites More sharing options...
maxxd Posted April 10, 2020 Share Posted April 10, 2020 Count the number of equals signs on that line. Remember 1 is for assignment, 2 is for comparison. Quote Link to comment https://forums.phpfreaks.com/topic/310528-help-using-num-rows/#findComment-1576671 Share on other sites More sharing options...
ginerjm Posted April 10, 2020 Share Posted April 10, 2020 And - num_rows is an integer. Don't compare it to a string. Quote Link to comment https://forums.phpfreaks.com/topic/310528-help-using-num-rows/#findComment-1576673 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.