$text = "here we have a long string of text with transaction ID: 1234V and some other stuff mixed in here.";
//lets cutup the string and only extract the transaction id
$array = explode("transaction ID: ", $text);
if (isset($array[1]))
$array = explode("and", $array[1]);
$variable = $array[0]; //$array[0] = '1234V ';
$trans = "SELECT * FROM `name` WHERE `transaction` = '$variable';";
if($statement = $mysqli->prepare("$trans")){
$statement->execute();
$statement->bind_result($id,$name,$transaction);
while ($statement->fetch()) {
printf("%s %s\n",$id,$name,$transaction);
}
$statement->close();
}
$mysqli->close();
die();
4条答案
按热度按时间r7knjye21#
id |名称|交易|
1 |大卫| 1234v|
在phpmyadmin中,以下非变量sql返回1行。但是,变量sql返回一个非函数资源。
我为$mysqli->query()尝试了各种sql语句和语法的重新安排;
我是不是在php.ini中遗漏了什么?
带有$变量的新代码如下:
新代码和硬代码打印如下:
ozxc1zmp2#
---------表
ars1skjm3#
xytpbqjk4#
你能试试这样的吗:
另外,我认为你应该这样做: