Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP与mysql\u fetch\u数组冲突?_Php_Mysql - Fatal编程技术网

PHP与mysql\u fetch\u数组冲突?

PHP与mysql\u fetch\u数组冲突?,php,mysql,Php,Mysql,我对mysql_fetch_数组有一个问题,下面是我的代码。还有一件事,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."'";

我对mysql_fetch_数组有一个问题,下面是我的代码。还有一件事,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上运行它时,它会发生:

mysql\u num\u rows和mysql\u fetch\u数组期望参数为resource,给定布尔值 这意味着变量$query的类型为“boolean”。之所以发生这种情况,是因为语句mysql\u query$selected$conex可能返回了错误的结果


检查SQL查询…

mysqli函数是一些小东西,可以帮助您修补代码中的漏洞。替换$query=mysql\u query$selected,$conex;如果$query=mysql\u query$selected,$conex或diemsql\u错误;你会得到错误的