PHP与mysql_fetch_array冲突?

时间:2013-11-30 07:59:30

标签: php mysql

我遇到mysql_fetch_array的问题,这是我的代码。另一件事,mysqli *函数是什么?

<?php
session_start();
include "config.php";
$conex = mysql_connect("localhost", "root");
$name = $_GET['name'];
$selected = "SELECT id,password,email,name FROM users WHERE username = '".$name."'";
$query = mysql_query($selected,$conex);
$rows = mysql_num_rows($query);
if($row = mysql_fetch_array($query))
{
        $username = $row['username'];
        $id = $row['id'];
        $password = $row['password'];
        $email = $row['email'];
}
?>

当我在WAMP上运行时,它会发生:

http://spectrum-solaris.besaba.com/stack3.PNG

1 个答案:

答案 0 :(得分:0)

mysql_num_rows() mysql_fetch_array()期望参数为资源,布尔值为”
意味着变量 $ query 的类型为'boolean'。发生这种情况是因为语句
mysql_query($ selected,$ conex)可能返回“false”结果。

检查SQL查询...