Tenaciousmug Posted November 8, 2011 Share Posted November 8, 2011 Here is my code: $sql = mysqli_prepare($cxn,'SELECT userId, salty, password FROM members WHERE userName=?'); mysqli_stmt_bind_param($sql,'s',$userName); mysqli_stmt_execute($sql); mysqli_stmt_bind_result($sql,$userId,$salty,$pass); echo $userName; echo $userId; echo $salty; echo $pass; What is happening is when I plug that query into the phpmyadmin, it pulls the data perfectly. But when I put it in my script and do the bind_result() function, it is getting a 0 userId and null salty and pass.... It acts like it's not grabbing any data. Am I doing this wrong or is the order I'm doing it wrong? Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/250742-mysqli_stmt_bind_result-error/ Share on other sites More sharing options...
xyph Posted November 8, 2011 Share Posted November 8, 2011 Not string with prepared statements, but I think you need to fetch the data mysqli_stmt::fetch Quote Link to comment https://forums.phpfreaks.com/topic/250742-mysqli_stmt_bind_result-error/#findComment-1286436 Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2011 Share Posted November 8, 2011 You need to use mysqli_stmt_init http://us3.php.net/manual/en/mysqli.stmt-init.php to create a statement object that you use with all the other related functions. There's an example in the mysqli_stmt_prepare documentation - http://us3.php.net/manual/en/mysqli-stmt.prepare.php Quote Link to comment https://forums.phpfreaks.com/topic/250742-mysqli_stmt_bind_result-error/#findComment-1286437 Share on other sites More sharing options...
xyph Posted November 9, 2011 Share Posted November 9, 2011 You need to use mysqli_stmt_init http://us3.php.net/manual/en/mysqli.stmt-init.php to create a statement object that you use with all the other related functions. There's an example in the mysqli_stmt_prepare documentation - http://us3.php.net/manual/en/mysqli-stmt.prepare.php Not entirely correct. mysqli_prepare does the init for him. Your is another correct method of doing this, though. Quote Link to comment https://forums.phpfreaks.com/topic/250742-mysqli_stmt_bind_result-error/#findComment-1286443 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.