嘿,我正在尝试验证我的 xml 文件中的用户名和密码是否与我的数据库中的相同,但 mysql_num_rows 为零。所以我的 SELECT 查询一定有问题。这是我的代码:
public function verifyDB()
{
//connection to database
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('proiect_is') or die(mysql_error());
$data =mysql_query("SELECT id FROM users WHERE userName ='$this->xml->parameters->username' AND password ='$this->xml->parameters->pass'");
//we check if any row was returned
echo $data;
echo $this->xml->parameters->username."<BR>";
echo $this->xml->parameters->pass."<BR>";
print_r(mysql_num_rows($data));
if (mysql_num_rows($data))
{
$row = mysql_fetch_assoc($data);
$this->_id= $row['id'];
echo $row;
return true;
}
else
{return false;}
}
这是我的 xml 登录文件:
<xml version="">
<action>log_in</action>
<parameters>
<username>Ionel P</username>
<pass>abdef01</pass>
</parameters>
</xml>