moxol Posted November 22, 2020 Share Posted November 22, 2020 I have a table korisnici in SQLite with INTEGER field aktivan that can have only 0 or 1 value (CHECK constraint). Field aktivan has value 0 but PHP returns value 1, why? Is this a bug? This is PHP code that I am running: $sql = "SELECT ime, aktivan FROM korisnici WHERE lower(ime) = '" . $ime . "'" . " AND sifra = '" . $_POST["sifra"] . "'"; $result = $db->query($sql); $row = $result->fetchArray(SQLITE3_ASSOC); $row['aktivan'] = 1 but in table the value is 0. When I run same query in DB Browser for SQLite I get correct value 0. Is this a bug? Quote Link to comment https://forums.phpfreaks.com/topic/311755-sqlite-query-from-php-returns-wrong-result/ Share on other sites More sharing options...
requinix Posted November 22, 2020 Share Posted November 22, 2020 There is a bug, but it is not with PHP or SQLite. Echo out the $sql and try that directly. Some value somewhere, either $ime or in $_POST or in your database, is not what you think it is. Quote Link to comment https://forums.phpfreaks.com/topic/311755-sqlite-query-from-php-returns-wrong-result/#findComment-1582590 Share on other sites More sharing options...
moxol Posted November 22, 2020 Author Share Posted November 22, 2020 I am little bit embarrassed to say, but there was a next line: if($row['aktivan']=1) Obviously, = should be == Sorry, I will take 🔨 and accelerate it towards my Quote Link to comment https://forums.phpfreaks.com/topic/311755-sqlite-query-from-php-returns-wrong-result/#findComment-1582592 Share on other sites More sharing options...
Barand Posted November 22, 2020 Share Posted November 22, 2020 3 hours ago, moxol said: Sorry, I will take 🔨 and accelerate it towards my I have an inflateable baseball bat which I often use on such occasions. 1 Quote Link to comment https://forums.phpfreaks.com/topic/311755-sqlite-query-from-php-returns-wrong-result/#findComment-1582607 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.