当我编写我的在线商店时,我收到了这个奇怪的错误消息,我之前从未见过它!
致命错误:在第5行的写入上下文中不能使用函数返回值
这是我的代码
<?php
if (isset($_GET['pro_id'])){
$product_id = $_GET['pro_id'];
$query = $con->query("SELECT * FROM viewcounter WHERE productcode='$product_id'");
if(mysqli_num_rows($query) = 0){
$insert_id = "insert into viewcounter (productcode) values ('$product_id')";
$insert_id = mysqli_query($con, $insert_id);
mysql_query("UPDATE viewcounter SET `views`=`views`+1 WHERE productcode='$product_id'")
}
$get_pro = "select * from products where product_id='$product_id'";
$run_pro = mysqli_query($con,$get_pro);
while($row_pro = mysqli_fetch_array($run_pro)){
$_SESSION['pro_id'] = $row_pro['product_id'];
$_SESSION['pro_cat'] = $row_pro['product_cat'];
$_SESSION['pro_brand'] = $row_pro['product_brand'];
$_SESSION['pro_title'] = $row_pro['product_title'];
$_SESSION['pro_price'] = $row_pro['product_price'];
echo '....';
";}}?>
这是第5行,我收到错误消息:
if(mysqli_num_rows($ query)= 0){
注意:我跳过编写连接数据库的代码,因为它已经没问题了!
答案 0 :(得分:2)
input.h
即将函数的值赋值为0
为了比较,您需要双倍或三倍:
if(mysqli_num_rows($query) = 0){