Jump to content
MakeWebGames

Mysqli question


Recommended Posts

Posted
$stmt = $mysqli->prepare('SELECT user_name from `user_details` where user_email = ?');
  	 $stmt->bind_param('s', $var);
  	 $stmt->execute() or $this->myerror[] = $stmt->error; 

 

Any idea why this wont work, and wont give a error?

Posted

The code is fine. It'll work if you're connected to the DB, SQL fields are correct and of course $var contains an email address. Try grabbing the results after the binding execute:

 

$stmt = $mysqli->prepare('SELECT user_name from `user_details` where user_email = ?');
$stmt->bind_param('s', $var);
$stmt->execute() or $this->myerror[] = $stmt->error;

$stmt->bind_result($user_name);
while ($stmt->fetch()) { 
   printf("Username is: %s \n", $user_name); 
}
Posted

Hey

Hey, the sql was fine but there was a error, i dident user $stmt->store_result to save it. Dont see how this helps when programming but it fixed it anyway :)

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.   Paste as plain text instead

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