//数据库连接<?php//$conn=mssql_connect("localhost","dabaxitong","dabaxitong","daba..") or die("数据库无法远程,请联系管理员!");//mssql_select_db("ouou") or die("做坏事?");header("Content-Type:text/html;charset=utf-8");$mysqli=new mysqli("localhost","da","da","da");//错误返回if(mysqli_connect_errno()){ printf("连接有问题 %s\n",mysqli_connect_error()); exit;}//设置编码if (!$mysqli->set_charset("utf8")) { printf("字符集utf8加载错误: %s\n", $mysqli->error);} else { //printf("设置当前字符集: %s\n", $mysqli->character_set_name());}$mysqli->query("set names 'utf8'");//写库$mysqli->query("set character set 'utf8'");//读库//$mysqli->close();
include './xitong/LianJieMySql.php';//查询 if ($row = $mysqli->query("select * from yonghu where MingZi_ShouJi = '$u'and MiMa='$p'")) { $r=$row->fetch_array(); print_r($r); }else { echo mysql_error(); }
在名字和密码正确的情况.而且数据库连接也正常,他就是查询不出来.一般这种问题,找错误,可以怎么找?
回复讨论(解决方案)
更奇怪的是.在phpmyadmin里查询
select * from yonghu where mingzishouji = '134213213';
也是0条返回.这个字段是有134213213
如果直接执行 select * from yonghu
的话,是可以print_t 的.
1但加入 where mingzishouji = '123' 就无法查询了. 该字段是有这123存在.
好了.是我见鬼了.原来是字段里的错误.