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
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

 

Not entirely correct. mysqli_prepare does the init for him. Your is another correct method of doing this, though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.