gpt4 book ai didi

linux - PHP 的 SELECT 语句问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:33:06 25 4
gpt4 key购买 nike

+--------------+------+
| IP | Say |
+--------------+------+
| 192.168.1.1 | 1 |
+--------------+------+

$con = mysqli_connect("$host", "$user", "$pass", "$db_name") or die("cannot connect");
$Q1 = "SELECT Say From spam_engel WHERE IP = '192.168.1.1'";
$ol = mysqli_query($con, $q1);
echo gettype($ol);

打印的东西是“NULL”。但它应该打印“int”......可能是什么问题?

最佳答案

PHP variables区分大小写:

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

所以在你的代码中:

$Q1 = "SELECT Say From spam_engel WHERE IP = '192.168.1.1'";
$ol = mysqli_query($con, $q1);

在这里你使用 $Q1 然后传递给你的 mysql_query() 小写变量 $q1;

要解决此问题,请统一变量名的大小写,如下所示:

$q1 = "SELECT Say From spam_engel WHERE IP = '192.168.1.1'";
$ol = mysqli_query($con, $q1);

关于linux - PHP 的 SELECT 语句问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42750022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com