dflynn Posted August 20, 2009 Share Posted August 20, 2009 Hi there, I'm new to the forums, not completely new to PHP though. Only recently have I started to play with Prepared Statements, so bare with me if my questions ound really stupid. I started learnign Prepared Statements through a Login script tutorial on Nettuts, so that's how I've been laying out my code. Anyway, I have three files. activate.php, activate_class.php and mysql.php. in activate.php I have the following: <?php session_start(); require_once 'classes/activate.php'; $activate = new Activate(); if($_POST && $user_handle !== "" && !empty($_GET['uid'])) { $return = $activate->activate_User($user_handle, $_GET['uid']); } ... uid is passed through the url. a different script I'm going to ask about later ensures the uid exists in the database and then returns the user's handle to be used on the page. So when the user sees the "activate your account" message and clicks activate that snippet is activated and leads to this, in activate_class.php: function activate_User($un, $pwd) { $mysql = new my_sql(); $activate = $mysql->activate_Uid($un, $pwd, 1); if($activate) { header("location: welcome.php"); } else return "failed to activate"; } and in the mysql.php file: function activate_Uid($un, $pwd, $verified) { $query = "UPDATE members SET user_verified = ? WHERE user_handle = ? AND user_password = ? LIMIT 1"; if($stmt = $this->conn->prepare($query)) { $stmt->bind_param('iss',$verified, $un, $pwd); $stmt->execute(); if($stmt->fetch()) { $stmt->close(); return true; } } } Everything works fine and the database inserts the 1 into user_verified. However when the if($activate) { header("location: welcome.php"); } else return "failed to activate"; } runs, it seems as though the Update function is returning false because it doesn't redirect. Instead it shows the "failed to activate" text. Any ideas why it would be returning false but still executing? Thanks. I think this might fix a few other errors I am having. Link to comment https://forums.phpfreaks.com/topic/171089-update-table-using-prepared-statements-issue/ Share on other sites More sharing options...
dflynn Posted August 21, 2009 Author Share Posted August 21, 2009 Any ideas why this would return backwards? I don't understand why it would do that:S Link to comment https://forums.phpfreaks.com/topic/171089-update-table-using-prepared-statements-issue/#findComment-902999 Share on other sites More sharing options...
corbin Posted August 21, 2009 Share Posted August 21, 2009 There's nothing to fetch on an update statement. Link to comment https://forums.phpfreaks.com/topic/171089-update-table-using-prepared-statements-issue/#findComment-903014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.