PHP mysqli条件大于或小于符号错误 [英] PHP mysqli condition greater than or less than symbol error

查看:222
本文介绍了PHP mysqli条件大于或小于符号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mysqli准备好的语句中遇到以下奇怪的问题

I am getting the following strange issue in mysqli prepared statement

这是我的示例查询和参数

This is my sample query and params

SELECT * from ecf_request WHERE id > ? OR id < ?
...
$stmt->bind_param("ii", $id, $id1); //5, 10

当我仅使用=条件时,它可以正常工作,但是对于><条件,则无法正常工作. 我收到"Number of variables doesn't match number of parameters in prepared statement"错误

When i use just = conditions it's working fine but for > and < conditions it's not working. I am getting "Number of variables doesn't match number of parameters in prepared statement" error

在准备好的语句中是否可以使用大于和小于符号?

Is it possible to use greater than and less than symbols in prepared statements ?

我需要为日期过滤条件实现它.在两个日期之间进行记录.

I need to implement it for date filter condition. records between two dates.

预先感谢

推荐答案

一个id不能同时变大或变小. 您同时给出了id >10id <10之类的条件.

one id cannot be greater and smaller to itself at the same time. you are giving a condition like id >10 and id <10 at the same time.

如果要同时选择id1和id2,请使用SELECT * from ecf_request WHERE id IN(?,?)而不是AND;如果要选择介于两者之间的所有内容,请使用SELECT * from ecf_request WHERE id BETWEEN ? AND ?

If you want both id1 and id2 to be selected use SELECT * from ecf_request WHERE id IN(?,?) instead of AND and if you want to select everything in between then use SELECT * from ecf_request WHERE id BETWEEN ? AND ?

这篇关于PHP mysqli条件大于或小于符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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