phprocker Posted October 29, 2010 Share Posted October 29, 2010 Hey all. My site has a config database table that has a column showlogin to set whether or not login functionality is enabled. I'm playing around with MySQLi, Classes, and Returns. My return is always 1. Where am I going wrong? test.php <?php // Start Session session_start(); // Production Settings ini_set('display_errors', 1); mysqli_report(MYSQLI_REPORT_ALL); include 'db.php'; $mysqli = new mysqli($host, $user, $pass, $db); class styles { function showlogin($show) { global $mysqli; $select = $mysqli->query("SELECT showlogin FROM config LIMIT 1"); $value = $select->fetch_object(); if ($value->showlogin = 1) { return 1; } return 0; } } $login = new styles(); echo $login->showlogin($show); ?> Link to comment https://forums.phpfreaks.com/topic/217164-why-is-this-return-always-1/ Share on other sites More sharing options...
btherl Posted October 29, 2010 Share Posted October 29, 2010 if ($value->showlogin = 1) { should be if ($value->showlogin == 1) { Even experienced programmers get that wrong every now and then Some programming languages will give you a warning if they see that kind of mistake. Link to comment https://forums.phpfreaks.com/topic/217164-why-is-this-return-always-1/#findComment-1127830 Share on other sites More sharing options...
phprocker Posted October 29, 2010 Author Share Posted October 29, 2010 Cheers mate! Link to comment https://forums.phpfreaks.com/topic/217164-why-is-this-return-always-1/#findComment-1127833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.