Mysqli查询错误

时间:2018-05-17 15:02:07

标签: php mysql mysqli

我在这行中有错误:

if(isset($_POST["B1"]) && @$_SESSION["done"]!="ture") {
$select="select id from user where username='$_POST[T2]' ";
$result=mysql_query($select);
$num=mysql_num_rows($result);
@$name=$_REQUEST['T2'];
@$pas=$_REQUEST['T3'];
if(($_POST['T2']=='')||($_POST['T3']=='')) ;

我想要mysqli这个代码

2 个答案:

答案 0 :(得分:0)

试试这个,我在你的变量数据库连接中确认了$conn

$select="select id from user where username=".$_POST[T2];
$result=mysqli_query($conn,$select);
$num=mysqli_num_rows($result);

答案 1 :(得分:0)

注意:未定义的变量:第106行的C:\ Wamp \ www \ online library \ register.php中的conn

警告:mysqli_query()要求参数1为mysqli,在第106行的C:\ Wamp \ www \ online library \ register.php中给出null
警告:mysqli_num_rows()期望参数1为mysqli_result,在第107行的C:\ Wamp \ www \ online library \ register.php中给出null

我的代码行:

if(isset($_POST["B1"]) && @$_SESSION["done"]!="ture") {
$select="select id from user where username=".$_POST['T2'];
$result=mysqli_query($conn,$select);
$num=mysqli_num_rows($result);
@$name=$_REQUEST['T2'];
@$pas=$_REQUEST['T3'];
if(($_POST['T2']=='')||($_POST['T3']=='')) ;