如何使用MySQLI多次绑定参数? [英] How to bind param multiple times with MySQLI?

查看:76
本文介绍了如何使用MySQLI多次绑定参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我绑定参数的方式:

This is how I'm binding my params:

$Con = mysqli_connect(...);
$Statement = mysqli_stmt_init($Con);

mysqli_stmt_prepare($Statement,"select * from users where name=? and email=?");
mysqli_stmt_bind_param("s",$Username);
mysqli_stmt_bind_param("s",$Email); <-- it fails here

但是在另一种情况下,当我将对mysqli_stmt_bind_param的2个调用替换为:

But it works fine in the other case when I replace the 2 calls to mysqli_stmt_bind_param with:

mysql_stmt_bind_param("ss",$Username,$Email)

问题是我有很多参数;我必须一一绑定它们,我不知道参数的数量

The problem is that I have an array of params; I have to bind them one by one coz I don't know the number of params

推荐答案

有点题外话,但我觉得它很重要.

A bit offtopic but I find it important enough.

手册页中有关mysql_stmt_bind_param的最近用户评论中包含了对该问题的确切答案.

A very recent user comment in the manual page for mysql_stmt_bind_param contains the exact answer to this very question.

您看到的,尽管鼓励懒惰,但该网站并不总是比旧的google和手册更好地回答您的问题.

You see, this site, although encourage laziness, not always answer your question better than good old google and manual can.

这篇关于如何使用MySQLI多次绑定参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆