我已经尝试了StackOverflow上列出的几个不同的脚本,它们都会出现同样的错误。我知道记录存在于数据库中。请帮忙或解答。
我试过最新的脚本: -
<?php
$team='West Ham';
$query = "SELECT * from analysed where team = '$team'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
echo " exists";
} else {
echo " Dont exists";
}
?>
我甚至尝试过
$query = "SELECT * from analysed where 1d = '1'";
和
$query = "SELECT * from analysed where 1d = 1";
并得到相同的错误
警告:mysql_num_rows()要求参数1为resource,boolean 在C:\ Program Files中给出 第14行的(x86)\ EasyPHP-5.3.8.1 \ www \ football \ test-update.php
答案 0 :(得分:0)
我不知道餐桌结构。我说不完美。 您可以通过
查看问题mysql_query($query) or die(mysql_error());
答案 1 :(得分:0)
您可以使用此代码段作为示例:
<?php
//CONNECT FIRST
$DB_SERVER = "dbhost";
$DB_USER = "dbuser";
$DB_PASSWORD = "dbpass";
$DB_NAME = "database";
$conn = new mysqli($DB_SERVER, $DB_USER, $DB_PASSWORD, $DB_NAME);
if ($conn->connect_error) {
die("Connection failed." . $conn->connect_error);
}
$user_name = "Radu Radu";
$query = "SELECT * from users where user_name='$user_name'";
$result = $conn->query($query);
if ($result->num_rows > 0) {
echo "User exist!";
} else {
echo "User does not exist!";
}
答案 2 :(得分:0)
期待您已经有数据库连接。
<?php
$team='West Ham';
$query=mysql_query("SELECT * from analysed WHERE team ='$team'");
$result = mysql_query($query);
$return_no_of_rows=mysql_num_rows($result);
if($return_no_of_rows>0)
{
echo "Return Atleast one row";
}
else
{
echo "Return Nothing";
die();
}
&GT;