Jump to content

mysqli_stmt_bind_result() error


Tenaciousmug

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/250742-mysqli_stmt_bind_result-error/
Share on other sites

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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.