mysql_fetch_assoc()期望参数1是资源,对象给出[重复]

mysql_fetch_assoc()期望参数1是资源,对象给出[重复]

问题描述:

Im trying to store the results from my query into a variable but get this error

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given

$result = mysqli_query($con,"Select objectID from objects where objectName = '$_POST[relations]'");


if($result === FALSE) {
    die(mysqli_error()); // TODO: better error handling
}

$result = mysql_fetch_assoc($result);
echo $result;

Any other way of storing this variable?

</div>

此问题已经存在 这里有一个答案: p>

You start with mysqli_*, but continue with mysql_*.

Change mysql_fetch_assoc to mysqli_fetch_assoc.

Documentation
You can view the documentation on mysqli_fetch_assoc here.